Reputation: 1819
I want to have a (semi-)transparent view on top of another view (a map) where I can place various elements as an overlay. With my current setup I have two problems, as shown in the image below:
a. the test rectangle appears always at the bottom (as a test I want it 40dp from the top)
b. the view is not entirely transparent, there is a greyish area above my test-rectangle
my layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/landmark"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="40dp">
<ImageView
android:id="@+id/box"
android:src = "@drawable/rectangle"
android:layout_alignParentBottom = "true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
activity class:
class LandmarkActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_landmark)
}
}
manifest:
<activity android:name=".LandmarkActivity"
android:launchMode="singleTask"
android:theme="@style/Theme.AppCompat.Dialog"
android:windowSoftInputMode="adjustResize|stateHidden"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Upvotes: 0
Views: 153
Reputation: 19243
try with this, without layout_alignParentBottom
and with proper top margin set
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/landmark"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="@+id/box"
android:src = "@drawable/rectangle"
android:layout_marginTop="40dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
ImageView
have android:src = "@drawable/rectangle"
with sizes set as wrap_content
so size of this View
depends on your drawable. you may consider adding adjustViewBounds
and scaleType
xml attrs to ImageView
, but without actual real rectangle
drawable its hard to guess is this will help
Upvotes: 1