Adrian
Adrian

Reputation: 301

What did I miss thing in the XML?

When I developed my app 1 years ago, the position was right, but now, something is wrong (cropped).

I don't know what I missed. I think I used the right things 'weight' attribute in the XML.

This is the code and the result in the phone. (Mine is Galaxy S6 Edge, Nougat)

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="1">

<TextView
    android:id="@+id/txt_qna_content"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_marginLeft="20dp"
    android:layout_marginTop="10dp"
    android:layout_weight="0.7"
    android:text="Content"
    android:textColor="#000" />

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.3"
    android:layout_marginBottom="5dp">

    <TextView
        android:id="@+id/txt_qna_regdtm"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_alignParentStart="true"
        android:paddingLeft="10dp"
        android:text="REG_DTM"
        android:textSize="10dp"
        android:textColor="#000" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentRight="true"
        android:gravity="right"
        android:orientation="horizontal">

        <Button
            android:id="@+id/btn_qna_update"
            android:layout_width="25dp"
            android:layout_height="25dp"
            android:layout_marginRight="10dp"
            android:background="@drawable/icon_qna_update"
            android:onClick="onClick"
            android:visibility="visible" />

        <Button
            android:id="@+id/btn_qna_answer"
            android:layout_width="25dp"
            android:layout_height="25dp"
            android:layout_marginRight="10dp"
            android:background="@drawable/icon_qna_answer"
            android:onClick="onClick"
            android:visibility="visible" />

        <Button
            android:id="@+id/btn_qna_delete"
            android:layout_width="25dp"
            android:layout_height="25dp"
            android:layout_marginRight="10dp"
            android:background="@drawable/icon_qna_delete"
            android:onClick="onClick"
            android:visibility="visible" />
    </LinearLayout>
</RelativeLayout>
</LinearLayout>

And the original picture is it!

Upvotes: 0

Views: 54

Answers (1)

Tenten Ponce
Tenten Ponce

Reputation: 2506

Try this:

        <Button
            android:id="@+id/btn_qna_update"
            android:layout_width="25dp"
            android:layout_height="wrap_content"
            android:layout_marginRight="10dp"
            android:background="@drawable/icon_qna_update"
            android:onClick="onClick"
            android:visibility="visible" />

It seems that you're limiting the height of the button that's why the image is getting cut. Try to use wrap_content.

Upvotes: 1

Related Questions