2016-04-06 22 views
0

Uygulamamı farklı çözünürlük ve ekran boyutlarında yapmaya çalışıyorum. Düzenler için ağırlık kullanırım ve mükemmel çalışır ancak metinler ve simgelerle ilgili problemler vardır (androidstudio'daki Vector Assets). Aslında metinler (ör. 20sp) ve simgeler (ör. 20dp) için sabit değer kullanıyorum ancak uygulama başka bir mobil ikonda açıkken çok küçük veya çok büyük. Xml dosyasında ekran boyutuna göre ölçeklendirmek mümkün mü?Android studio icon anc text scale

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context="com.hgyghyfghyu.apkana40.TrainerMenu" 
android:orientation="vertical" 
android:layout_marginLeft="10dp" 
android:layout_marginRight="10dp" 
android:layout_marginBottom="10dp"> 

// 
<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="2" 
    android:background="#000000" 
    android:layout_marginBottom="10dp" 
    android:id="@+id/colorsdialogbtn"> 
</LinearLayout> 

// 
<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="2" 
    android:layout_marginBottom="10dp" 
    android:layout_marginTop="10dp" 
    android:orientation="horizontal"> 
    // 
    <LinearLayout 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_weight="1" 
     android:background="#000000" 
     android:layout_marginLeft="10dp" 
     android:layout_marginRight="10dp" 
     android:id="@+id/trainermenugroupsbtn"> 
     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 
      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/trainermenugroupsicon" 
       android:tint="#FFFFFF" 
       android:layout_centerInParent="true" 
       android:src="@drawable/trainermenugroupsicon"/> 
      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerHorizontal="true" 
       android:layout_below="@+id/trainermenugroupsicon" 
       android:textSize="25dp" 
       android:textStyle="bold" 
       android:text="" 
       android:textColor="#FFFFFF"/> 
     </RelativeLayout> 
    </LinearLayout> 
    // 
    <LinearLayout 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_weight="1" 
     android:background="#000000" 
     android:layout_marginLeft="10dp" 
     android:layout_marginRight="10dp" 
     android:id="@+id/trainermenutrainersbtn"> 
     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 
      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/trainermenutrainersicon" 
       android:tint="#FFFFFF" 
       android:layout_centerInParent="true" 
       android:src="@drawable/trainermenutrainersicon"/> 
      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerHorizontal="true" 
       android:layout_below="@+id/trainermenutrainersicon" 
       android:textSize="25dp" 
       android:textStyle="bold" 
       android:text="" 
       android:textColor="#FFFFFF"/> 
     </RelativeLayout> 
    </LinearLayout> 

</LinearLayout> 

// 
<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1" 
    android:layout_marginTop="10dp" 
    android:layout_marginBottom="10dp" 
    android:orientation="horizontal"> 
    // 
    <LinearLayout 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_weight="2" 
     android:background="#000000" 
     android:id="@+id/trainermenuadbtn" 
     android:layout_marginRight="10dp" 
     android:layout_marginLeft="10dp" 
     android:layout_marginBottom="10dp"> 
     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:paddingTop="10dp"> 
      <ImageView 
       android:id="@+id/trainermenuadicon" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:tint="#FFFFFF" 
       android:src="@drawable/trainermenuadicon" 
       android:layout_alignParentTop="true" 
       android:layout_centerHorizontal="true"/> 
      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/trainermenuadicon" 
       android:layout_centerHorizontal="true" 
       android:textSize="15dp" 
       android:text="" 
       android:textStyle="bold" 
       android:textColor="#FFFFFF"/> 
     </RelativeLayout> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_weight="2" 
     android:orientation="horizontal" 
     android:layout_marginLeft="10dp" 
     android:layout_marginRight="10dp"> 
     //info 
     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:background="#000000" 
      android:id="@+id/trainermenuinfobtn" 
      android:layout_marginRight="10dp" 
      android:layout_marginBottom="10dp"> 
      <RelativeLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"> 
       <ImageView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:tint="#FFFFFF" 
        android:src="@drawable/trainermenuinfoicon" 
        android:layout_centerInParent="true"/> 
      </RelativeLayout> 
     </LinearLayout> 


     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:background="#000000" 
      android:id="@+id/trainermenusettingsbtn" 
      android:layout_marginLeft="10dp" 
      android:layout_marginBottom="10dp"> 
      <RelativeLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"> 
       <ImageView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:tint="#FFFFFF" 
        android:layout_centerInParent="true" 
        android:src="@drawable/trainermenusettingicon"/> 
      </RelativeLayout> 
     </LinearLayout> 
    </LinearLayout> 
</LinearLayout> 

+0

mmm'e bakıyorum, iyi bir "xml" tasarımınız olmadığını düşünüyorum ... – Aspicas

+0

bu ne anlama geliyor? – littlewombat

+0

Eğer xml'iniz iyi tasarlanmışsa, resimleriniz otomatik olarak – Aspicas

cevap

0

Eğer ekranına göre metin boyutu ve görüntü boyutunu tanımlamak ekran boyutu ve yeri dimen.xml dosyaya göre değer klasör oluşturun ve metin boyutu ve görüntü boyutunu tanımlamak, bu değerleri kullanmak isterseniz düzeni. 1)

2) değerleri-hdpi (320x480, 480x800) değerleri

3) değerler büyük hdpi (600x1024)

4) değerler xlarge (720x1280, 768x1280, 800x1280, Nexus7, Nexus10)

5) değerler sw480dp (5.1' WVGA ekran)

6) değerleri,-xhdpi (Nexus4 Galaxy Nexus)

Ayrıca yer dif hdpi, xlarge vb. için ferent görüntüler. Sadece gerekli klasörleri oluşturun. Daha fazla ayrıntı için http://developer.android.com/guide/practices/screens_support.html

+0

Bu yüzden ekran boyutu almak ve android ile kullanmak imkansız: scaleX = "" xml? – littlewombat

+0

Hayır, ekran boyutunu elde etmek imkansız değil, ekran boyutunu programlı olarak alabilir ve daha sonra scaleX programaticaly'yi kullanabilirsiniz. – USKMobility

+0

Bunun, görüntü boyutunu, OnCreate'daki file.java'dan ayarlamasının iyi bir fikir olduğunu mu düşünüyorsunuz? – littlewombat