Android 将SeekBar和ImageButton置于相对位置
我有以下xml:Android 将SeekBar和ImageButton置于相对位置,android,Android,我有以下xml: <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" > <ImageButton android:id="@+id/reset" android:src="@drawable/ic_action_refresh" android:layout_width="wr
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageButton
android:id="@+id/reset"
android:src="@drawable/ic_action_refresh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/reset"
android:onClick="reset"
android:layout_alignParentRight="true" />
<SeekBar
android:id="@+id/seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/reset" />
</RelativeLayout>
我试着使用重心和布局,但没有成功。如何使RelativeLayout的内容居中?您可以使用以下三种方法之一进行相对布局: 设置为真 设置为真 设置为真 使用以下代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageButton
android:id="@+id/reset"
android:src="@drawable/ic_action_refresh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/reset"
android:onClick="reset"
android:layout_alignParentRight="true"
android:layout_centerHorizontal="true" />
<SeekBar
android:id="@+id/seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/reset"
android:layout_centerHorizontal="true" />
</RelativeLayout>
你在哪里应用了layout_gravity属性?layout_gravity将在其父级中设置RelativeLayout的重力。请根据你的要求放置屏幕截图,我不清楚。