Sri*_*man 6 android android-layout android-linearlayout android-button
我知道这可以通过使用相对布局很容易地完成,但我觉得我正在做的是正确的,并且应该使用线性布局本身给我想要的结果.但出于某种原因,当我在运行Android JB 4.1.2的Google Nexus 7上运行时,我会在列表视图项之后立即看到按钮和文本视图.如果列表视图为空,我会在屏幕顶部看到它们.难道我做错了什么??这是我的xml文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/attachments_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="1"
android:orientation="vertical">
<ListView
android:id="@+id/mtg_attachments"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<Button
android:id="@+id/attach_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/delete"
android:textSize="22sp" />
<TextView
android:text="@string/attach_warning"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
如果您想将某个项目置于屏幕中央,请不要使用 LinearLayout,因为它们用于显示连续堆叠的多个项目。
请改用RelativeLayout。
所以替换:
android:layout_gravity="center"
Run Code Online (Sandbox Code Playgroud)
对于相关RelativeLayout选项:
android:layout_centerInParent="true"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3274 次 |
| 最近记录: |