2012-04-24 8 views
0

앱의 기본 화면 레이아웃이 있습니다.이 레이아웃은 evernote 스타일을 갖고 싶습니다. 지금까지, 내 ​​코드는 이것이다 :Android : Evernote 스타일 레이아웃

<?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> 

이는 모습입니다 같은 :

enter image description here

그리고 이것은 내가 모양을하고 싶은 방법입니다

enter image description here

어떻게하면됩니까? 이런 식으로 단추를 그룹화할까요?

미리 감사드립니다.

+1

은 당신이 아마 찾고있는 것은 대시 보드 패턴이다. 이 질문을 확인하십시오 : http://stackoverflow.com/questions/2873568/android-dashboard-pattern - 두 번째 대답 –

+0

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

답변

1

당신이 구글 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

또 다른 문제점은 텍스트보기가 확대되지 않지만 이미지로보기에는 그리 큰 문제가 아니라는 것입니다. –

+0

@kilaka 이것은 위치 지정을위한 예일뿐입니다. 제 경우에는 단추를 사용 했으므로 원하는 것을 넣을 수 있습니다. 내 애플 리케이션에서 잘 작동, 나는'Evernote'와 비슷한 것을 가지고있다. –

1

ImageButtons의 너비를 0dp로 설정하고 1의 layout_weight를 지정하면됩니다. layout_gravity를 center_horizontal로 설정합니다.

이렇게하면 센터를 멋지게 만듭니다.

행복을 빌며, 팀