我想要做如何爲Android的活動
在我創造了我的活動,其中有別樣的在它的「盒子」設計中的彎矩設計偉大的設計的。這些「盒子」中的每一個都有不同的信息。我在一張紙上手工創建了這個設計,但我不會在我的.xml文件中把這個想法寫下來!
問題
在這篇文章,你會發現一個拷入「盒子」,我想創建我的應用程序,它的底部。請幫助我認識到這一點,因爲我真的不知道如何在XML中做到這一點!我正在使用Android 4.0(ICS)。
我想要做如何爲Android的活動
在我創造了我的活動,其中有別樣的在它的「盒子」設計中的彎矩設計偉大的設計的。這些「盒子」中的每一個都有不同的信息。我在一張紙上手工創建了這個設計,但我不會在我的.xml文件中把這個想法寫下來!
問題
在這篇文章,你會發現一個拷入「盒子」,我想創建我的應用程序,它的底部。請幫助我認識到這一點,因爲我真的不知道如何在XML中做到這一點!我正在使用Android 4.0(ICS)。
像這樣的東西應該工作:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/box_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Box Title" />
<LinearLayout
android:id="@+id/box_content"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<LinearLayout
android:id="@+id/box_content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:id="@+id/box_content_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hans Max" />
<TextView
android:id="@+id/box_content_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Maxiburger 12" />
<TextView
android:id="@+id/box_content_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="8002, Muster" />
</LinearLayout>
<ImageButton
android:id="@+id/box_button"
android:layout_weight="5"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
</LinearLayout>
我給你的僞佈局:
<RelativeLayout>
<TextView
full width
id:infobox/>
<Button
layoutParentRight
below infobox/>
<TextView
layout_below infobox
toLeftOf button/>
// repeat the textView above and always below the previous one
</RelativeLayout>
隨着LinearLayouts:
<LinearLayout>
<TextView infobox/>
<LinearLayout>
<LinearLayout>
<TextView />
<TextView />
<TextView />
</LinearLayout>
<Button/>
</LinearLayout>
</LinearLayout>
正如你看到的是更加複雜和臃腫。由於我總是被水平/垂直方向所困惑,所以我將其留給你找出:) 只是做實驗,如果你不能使它工作,用你試過的佈局更新你的答案。
好吧,但我知道是有很多問題的時候,屏幕分辨率的變化或不?這可以通過Linearlayouts實現嗎? – safari
當然,你比他們需要三個。屏幕分辨率的「問題」仍然存在。你只需要儘可能地動態化。 – WarrenFaith
如果您使用相對佈局而沒有任何硬編碼,它將適用於所有分辨率。 –
嘗試了!感謝您的超級快速安納塞爾!這真的幫了很多!謝謝!!! – safari
我喜歡它,如果我們做*不*他們的工作。這是一個基本的佈局,他們應該早晚學會,爲什麼不現在呢? – WarrenFaith
@WarrenFaith在我看到這個佈局後,我學到了很多東西。首先我喜歡自己做這項工作,因爲我想學習這個!沒有惡意!我真的很感謝!併爲您的評論+1,因爲你是對的!我以同樣的方式看到它,但有時它有助於瞭解它,不知何故,您需要了解它的結構和構建方式! – safari