Reputation: 1043
I need to do like this where green icon is aligned by its baseline to top of this white card
In my case i can just align top part of green icon to top part of white card. layout_marginTop for green icon doen't allow to move it to top in this case.
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.wearable.view.CardFrame
android:id="@+id/card_home"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TEXT"
android:textColor="@color/black"/>
</android.support.wearable.view.CardFrame>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/menu"
android:layout_alignRight="@id/card_home"
android:layout_alignTop="@id/card_home"
android:layout_marginBottom="30dp"/>
</RelativeLayout>
Upvotes: 2
Views: 1545
Reputation: 2452
You can try with negativ margin-top
<ImageView
...
android:layout_marginTop="-30dp"
.../>
Upvotes: 1
Reputation: 25399
You're on the right track. Try like this, the trick is to replace marginBottom in your <ImageView>
with marginTop and assign to it a negative value, for example:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/card_home"
android:layout_width="100dp"
android:layout_height="100dp"
android:background="#FF00FFFF"
android:layout_centerInParent="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TEXT"
android:textColor="#ff000000"/>
</FrameLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/abc_btn_check_to_on_mtrl_015"
android:layout_alignRight="@id/card_home"
android:layout_alignTop="@id/card_home"
android:layout_marginTop="-15dp"/>
</RelativeLayout>
Notice the last line: android:layout_marginTop="-15dp"
This gives me something like this:
Upvotes: 1