【发布时间】:2014-07-04 08:22:06
【问题描述】:
我在我的 Android 布局中使用片段。如何设置片段布局的高度?
这是 activity_main.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:orientation="vertical" >
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Fragment No.1"
android:onClick="selectFrag" />
<Button
android:id="@+id/button2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="selectFrag"
android:text="Fragment No.2" />
<fragment
android:name="com.android.fragmentstest.FragmentOne"
android:id="@+id/fragment_place"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
这是 fragment.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="40dp"
android:layout_height="20dp"
android:id="@+id/tutlist_fragment"
android:layout_weight="45"
android:background="#7bae16">
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_weight="1"
android:text="This is fragment No.1"
android:textStyle="bold" />
</RelativeLayout>
我需要设置片段的最大高度和片段的位置。我将如何实现这一目标?
【问题讨论】:
-
你想达到什么目的??你的问题不清楚..
标签: android xml android-layout user-interface android-fragments