2013-04-24 2 views
0
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/lyt_parent" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@drawable/plain_bg" 
android:orientation="vertical" > 

<LinearLayout 
    android:id="@+id/lyt_header" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" > 

    <include 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     layout="@layout/header" /> 
</LinearLayout> 

<LinearLayout 
    android:id="@+id/lyt_body" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <RelativeLayout 
     android:id="@+id/lyt_Buttons" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" > 

     <ImageView 
      android:id="@+id/imgfrontlogo" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignLeft="@+id/imgcenterlogo" 
      android:layout_alignParentTop="true" 
      android:layout_marginTop="61dp" 
      android:background="@drawable/front_logo" 
      /> 

     <ImageView 
      android:id="@+id/imgcenterlogo" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignBottom="@+id/btnPersonaltrainer" 
      android:layout_centerHorizontal="true" 
      android:layout_marginBottom="29dp" 
      android:background="@drawable/center_logo" /> 

     <Button 
      android:id="@+id/btnMyProfile" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:layout_alignParentLeft="true" 
      android:layout_marginBottom="21dp" 
      android:layout_marginLeft="32dp" 
      android:background="@drawable/myprofile" /> 

     <Button 
      android:id="@+id/btnTaracker" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignBottom="@+id/imgcenterlogo" 
      android:layout_alignParentRight="true" 
      android:layout_marginBottom="49dp" 
      android:background="@drawable/track" /> 

     <Button 
      android:id="@+id/btnPersonaltrainer" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignBottom="@+id/btnMyProfile" 
      android:layout_alignLeft="@+id/btnAllExercises" 
      android:background="@drawable/personaltrainer" /> 

     <Button 
      android:id="@+id/btnRandomworkouts" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_above="@+id/btnPersonaltrainer" 
      android:layout_alignParentLeft="true" 
      android:background="@drawable/randomworkout" /> 

     <Button 
      android:id="@+id/btnAllworkouts" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignBaseline="@+id/btnAllExercises" 
      android:layout_alignBottom="@+id/btnAllExercises" 
      android:layout_alignLeft="@+id/btnMyProfile" 
      android:background="@drawable/allworkouts" /> 

     <Button 
      android:id="@+id/btnAllExercises" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_above="@+id/btnTaracker" 
      android:layout_alignParentRight="true" 
      android:layout_marginRight="40dp" 
      android:background="@drawable/allexercises" /> 

      </RelativeLayout> 
      </LinearLayout> 

      </LinearLayout>` 

모든 화면 크기에 호환되는 레이아웃을 만들어야하고, xlarge 크기 (800x1280,720x1280 등)의 separte 레이아웃을 만들어야합니다. 여기 평판 때문에 이미지를 업로드 할 수 없으며 레이아웃의 중앙에 하나의 메인 버튼을 배치하고 중간 버튼의 왼쪽과 오른쪽에 3 개의 버튼을 배치해야합니다. 모든 사람이 레이아웃없이 모든 화면 크기에 호환되는 레이아웃을 만들 수 있습니다. dp 또는 고정 점을 사용합니다.모든 화면 크기와 호환되는 여러 버튼이있는 상대적 레이아웃을 만드는 방법은 무엇입니까?

답변

0

android:layout_weight 속성을 사용할 수 있습니다. 백분율을 사용하여 버튼을 정의 할 수 있습니다. EX에 대한

:

<LinearLayout 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:weightSum="1.0" > 

    <Button 
     android:text="left" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight=".50" /> 

    <Button 
     android:text="right" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight=".50" /> 

</LinearLayout> 

들이 화면 전체의 그들의 %의 값으로 화면 크기에 표시 할 수 있도록 이제 버튼에 백분율 값을 주었다.

이것은 당신이 버튼이 왼쪽과 가운데 버튼의 오른쪽에 curvely 배치하고 싶은 질문에서 언급 한 바와 같이이 link

+0

답장을 보내 주셔서 감사합니다. 그러나 여기서는 배치 버튼에 상대적 레이아웃을 사용하고 있기 때문에 layout_weight 속성을 설정할 수 없습니다. 7 개의 버튼, 가운데 버튼 하나와 커브 버튼 3 개가 가운데 버튼의 왼쪽과 오른쪽에 있습니다. m 정렬 문제에 직면 해 있습니다. 여기 스크린 샷을 업로드 할 수 없습니다. 여기에 이메일 ID를 언급하면 ​​이미지를 보낼 수 있습니다. – Kishore

+0

내 대답의 마지막 줄에 제공된 링크를 확인하십시오. 상대적 레이아웃에 대한 답변도 있습니다. – Shiv

+0

미안하지만 해결책을 얻지 못합니다. – Kishore

0

RelativeLayout 검사 두 번째 대답을 LinearLayout 수행 할 수 있습니다, 당신은 한 번 봐 가질 수 링크를 통해이를 수행하는 방법에 대한 아이디어를 얻을 수 있습니다. https://github.com/daCapricorn/ArcMenu 이것은 Path like 메뉴를 만들기 위해 언급 한 오픈 소스 프로젝트입니다.

관련 문제