2013-08-18 3 views
0

각 기기의 해상도마다 안드로이드 LinearLayout을 사용합니다. 이 방법은 수직 레이아웃 문제 해결 다른 해상도.안드로이드 레이아웃 세로/가로 가중치

하지만 가로 레이아웃 문제를 해결할 수 없습니다. 내 레이아웃이야. 이런 레이아웃을 빌드하고 싶습니다. 내가 마진/오른쪽에서 왼쪽 그러나 이것은 다른 해상도에서 작동하지되어 사용이 경우

enter image description here

. TextView는 해상도 관련 장소입니까?

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/LinearLayout1" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@drawable/background" 
android:orientation="vertical" > 

<TextView 
    android:id="@+id/titleView" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_weight="9" 
    android:gravity="center" 
    android:text="TextView" 
    android:textColor="#5a5856" 
    android:textSize="35sp" /> 

<TextView 
    android:id="@+id/wordDafinitionView" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_weight="3" 
    android:textSize="17sp" 
    android:layout_marginLeft="25dp" 
    android:layout_marginRight="30dp" 
    android:text="TextView" 
    android:textColor="#5a5856" /> 


<TextView 
    android:id="@+id/TextView01" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_weight="9" 
    android:gravity="center" 
    android:text="TextView" 
    android:textColor="#5a5856" 
    android:textSize="35sp" /> 

</LinearLayout> 
+0

당신의'screenshot'은'Referral Denied'라고 말합니다 –

답변

0

하나의 해결책은

if((metrics.heightPixels/metrics.density) >= 700) 
       { 
        Log.e(" 10 inch Tab", " 10 inch Tab"); 
       } 
      else if((metrics.heightPixels/metrics.density) >= 550) 
       { 
        Log.e(" 7 inch Tab", " 7 inch Tab"); 
       } 
      else if((metrics.heightPixels/metrics.density) >= 400) 
       { 
        Log.e(" 5 inch Tab/Mobile", " 5 inch Tab/Mobile"); 
       } 
      else 
       { 
        Log.e("All other mobile devices", "All mobile other devices"); 
       } 

다음은 그에 따라 텍스트 뷰의 폭을 설정, 당신은

DisplayMetrics metrics = getResources().getDisplayMetrics(); 
int width = metrics.widthPixels; 
int height = metrics.heightPixels; 

으로 화면 크기를 읽고 다른 장치의 화면 크기를 확인할 수 있습니다.

+0

이것은 저에게 효과적입니다 :) – user2637015

관련 문제