ser*_*man 4 android alignment android-linearlayout
我想将图像放在视图的右侧.为此,我正在使用类似的东西
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
...some other elements
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<ImageView
android:id="@+id/imageIcon"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:src="@drawable/image_icon" >
</ImageView>
</LinearLayout>
...
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
以上似乎把图像放在了中心位置.无论我们处于纵向还是横向模式,如何确保图像右对齐?
感谢名单!
以下似乎有效.两个更改1.使用orientation = vertical,如Zortkun所建议2.在layout_width中使用wrap_content.
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="@+id/settingsIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:src="@drawable/settings_icon" >
</ImageView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13367 次 |
| 最近记录: |