Reputation: 6807
I still dont really get it how many space layouts take.
I have the following xml.
The inner LinearLayout's
for the bottom space height is set to wrap_content
, so it should take the height of the maximum height in there. Which is 52dp
. And there is the ImageButton
which is set to wrap_content
, so the button should be centered vertically on the right side, since its an 24dp
image (in xhdpi it has 32x32 pixels). So why is it stretched over the full height like displayed here?:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="2dp">
<de.ph1b.audiobook.utils.SquareImageView
android:id="@+id/cover"
android:scaleType="fitXY"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:layout_gravity="bottom">
<TextView
android:id="@+id/title"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="52dp"
android:paddingLeft="16dp"
android:maxLines="2"
android:ellipsize="end"
android:paddingRight="16dp"
android:gravity="center_vertical"
android:textSize="16sp" />
<ImageButton
android:id="@+id/editBook"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/borderlessButtonStyle"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_more_vert_grey600_24dp" />
</LinearLayout>
</LinearLayout>
Upvotes: 0
Views: 492
Reputation: 2877
change your image button code
<ImageButton
android:id="@+id/editBook"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/borderlessButtonStyle"
android:scaleType="fitXY"
android:gravity="center_vertical"
android:src="@drawable/ic_more_vert_grey600_24dp" />
Upvotes: 0
Reputation: 2692
either @drawable/ic_more_vert_grey600_24dp
is larger than you think or borderlessButtonStyle
has a larger background.
Please check the size. I have replicated the behavior and the ImageButton
is set to wrap_content
and is centered.
Upvotes: 1