ios*_*per 8 layout android textview
在我的应用程序中,我想在屏幕顶部显示一个带有屏幕宽度的TextView.接下来要在TextView下面显示图形视图.接下来在图形视图下方显示一个文本视图.
我使用了以下xml代码.在我的代码中,TextView无法显示在screeen的底部.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
android:background="#FF8A11"
android:padding="8dip"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<com.game.viewdot.ViewDot
android:id="@+id/DrawView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="bottom"
android:layout_gravity="bottom"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Another Text View"
android:background="#FF8A11"
android:padding="8dip"
android:gravity="bottom"
android:layout_gravity="bottom"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我希望在此代码中进行哪些修改以获得我的结果??????
小智 13
试试这个
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_gravity="bottom">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/ContentView"
android:layout_gravity="bottom" android:layout_alignParentBottom="true"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
而不是使用LinearLayout作为父布局使用相对布局.尝试使用以下代码
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/relative01"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
android:background="#FF8A11"
android:padding="8dip"
android:id="@+id/textView01"
/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/textView01"
>
<com.game.viewdot.ViewDot
android:id="@+id/DrawView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Another Text View"
android:background="#FF8A11"
android:padding="8dip"
/>
</LinearLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
希望对你有帮助...:)
| 归档时间: |
|
| 查看次数: |
42627 次 |
| 最近记录: |