내 XML 코드가는 : layout_gravity = "오른쪽"안드로이드 XML 여기에 작동하지
<?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="match_parent"
android:baselineAligned="false"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="5"
android:orientation="vertical" >
<TextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp" />
<TextView
android:id="@+id/tv_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="2"
android:gravity="center" >
<ImageView
android:id="@+id/iv_image"
android:layout_width="50dp"
android:layout_height="40dp"
android:background="@drawable/app_icon_17"
android:contentDescription="@string/empty" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_weight="2"
android:gravity="center" >
<Button
android:id="@+id/btn_delete"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="@drawable/btn_delete_new"
android:focusable="false" />
</LinearLayout>
</LinearLayout>
이다 나는 오른쪽 정렬 머물 아이디 btn_delete와 마지막 단추를 원한다. 그리고 디자인하면서 "그래픽 레이아웃"에서 원하는대로 보여줍니다. 하지만 에뮬레이터를 실행하면 작동하지 않습니다.
내가 생각하는'RelativeLayout'는 나'FrameLayout' 다음 모두 다음 더 나은'LinearLayout' 당신은 당신이 원하는 것을 얻을 것이다 .. 나는 목록 행 이러한 유형의 디자인 등'RelativeLayout'을 선호했다. – user370305
버튼에 layout_gravity를 추가하고 사용해보세요! – Gridtestmail
이기 때문에 수평 선형 레이아웃은 layout_gravity 오른쪽, 왼쪽 및 수평 중심을 무시하기 때문입니다. 수직 중력에만주의를 기울입니다. – njzk2