2012-04-24 2 views
0

私はアプリのメイン画面のレイアウトを持っています。これはevernoteスタイルを持ちたいと思っています。 はこれまでのところ、私のコードはこれです:Android:Evernoteスタイルのレイアウト

enter image description here

そして、これは私はそれがどのように見えるしたい方法です:

enter image description here

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="fill_parent" 
    android:gravity="center_vertical|center_horizontal" 
    android:orientation="vertical" > 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom|left" 
     android:orientation="horizontal" > 

     <ImageButton 
      android:id="@+id/btn1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/button" /> 

     <ImageButton 
      android:id="@+id/btn2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/button" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom|center" 
     android:orientation="horizontal" > 

     <ImageButton 
      android:id="@+id/btn3" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/button" /> 

     <ImageButton 
      android:id="@+id/btn4" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/button" /> 
    </LinearLayout> 

</LinearLayout> 

これは、それがどのように見えるかです

これをどのように達成できますか?このようなボタンをグループ化しますか?

ありがとうございます!

+1

は、ダッシュボードパターンです。この質問をチェックする:http://stackoverflow.com/questions/2873568/android-dashboard-pattern-第2の回答 –

+0

http://stackoverflow.com/questions/8212035/android-gridlayout-and-space-backport – Siyamed

答えて

1

あなたはこれがGoogleのI/Oアプリからで、これにそれを適応させることができます。あなたはおそらく探しているもの

<?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" 
android:background="#ffffff"> 
<LinearLayout android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" 
    android:padding="6dip"> 
    <LinearLayout android:orientation="horizontal" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1"> 
     <Button android:id="@+id/button" 
      android:text="@string/button" 
      android:drawableTop="@drawable/button" /> 
     <Button android:id="@+id/button" 
      android:text="@string/button" 
      android:drawableTop="@drawable/button" /> 
    </LinearLayout> 

    <LinearLayout android:orientation="horizontal" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1"> 
     <Button android:id="@+id/button" 
      android:text="@string/button" 
      android:drawableTop="@drawable/button" /> 
     <Button android:id="@+id/button" 
      android:text="@string/button" 
      android:drawableTop="@drawable/button" /> 

    </LinearLayout> 

    <LinearLayout android:orientation="horizontal" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1"> 
     <Button android:id="@+id/button" 
      android:text="@string/button" 
      android:drawableTop="@drawable/button" /> 
     <Button android:id="@+id/button" 
      android:text="@string/button" 
      android:drawableTop="@drawable/button" /> 
    </LinearLayout> 
</LinearLayout> 

+0

ボタン拡大しないでください。つまり、拡大しません。ですから、TextViewでImageViewを使うことをお勧めします。 –

+0

もう1つの問題は、テキストビューもスケールアップされないことですが、イメージとしては大きな問題ではありません。 –

+0

@kilakaこれは単なるポジショニングの例でした。私の場合、私はボタンを使用して、彼は何でも望みどおりに置くことができます。私のアプリではうまく動作します。私は 'Evernote'に似たものを持っています。 –

1

ImageButtonの幅を0dpに設定し、layout_weightに1を設定するだけです。 さらに、layout_gravityをcenter_horizo​​ntalに設定します。

これは、それらが中心にうまくいくようにします。

幸運を祈り、 ティム

関連する問題