我在 XML 中遗漏了什么?
What did I miss thing in the XML?
1年前我开发app的时候,位置是对的,但现在有点不对劲(裁剪)。
我不知道我错过了什么。我认为我在 XML.
中使用了正确的 'weight' 属性
这是phone中的代码和结果。 (我的是 Galaxy S6 Edge,牛轧糖)
<?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>
原图就是它!
试试这个:
<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" />
您似乎限制了按钮的高度,这就是图像被剪切的原因。尝试使用 wrap_content
.
1年前我开发app的时候,位置是对的,但现在有点不对劲(裁剪)。
我不知道我错过了什么。我认为我在 XML.
中使用了正确的 'weight' 属性这是phone中的代码和结果。 (我的是 Galaxy S6 Edge,牛轧糖)
<?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>
原图就是它!
试试这个:
<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" />
您似乎限制了按钮的高度,这就是图像被剪切的原因。尝试使用 wrap_content
.