您好我正在创建天气小部件应用程序。我已完成编程部分。我不熟悉布局设计。请帮我如何设计这个布局。在此先感谢。
答案 0 :(得分:2)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
android:layout_weight="1" >
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<TextView
android:id="@+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>
</LinearLayout>
这正是您现在想要的根据您的需要对所有小部件进行游戏....
答案 1 :(得分:2)
按照这样说:
LL(Ver)
LL(Hor)
LL(Ver)
TV
TV
FL
IV (match_parent for height and width)
TV (wrap_content for both)
LL(Hor)
TV (weight = 1)
TV (weight = 1)
TV (weight = 1)
LL:LinearLayout 电视:TextView FL:FrameLayout IV:ImageView
答案 2 :(得分:1)
按照以下方式行事 创建根LinearLayout
<LinearLayout 1
orienation should be vertical dont close it >
<LinearLayout 2
orientation should be horizontal for adding upper row dont close it to >
<LinearLayout 3
orientation should be vertical to add 2 textview
add 2 textview inside it close it />
<LinearLayout 4
orientation again should be vertical to add textview and image view
add textview and imageview to it and close it />
Now close LinearLayout 2 />
<LinearLayout 5
orienation should be horizontal to add 3 textview
add them inside this LinearLayout and close it />
Then close LinearLayout1 your root LinearLayout />
答案 3 :(得分:0)
使用以下代码,它将正常运行
script.inline: true