SORU
13 ŞUBAT 2011, Pazar


Android Düzeni Ağırlık

Android geliştirme için yeni duyuyorum ve doğrusal bir düzen içinde ağırlık ayarı ile ilgili bir sorum var.

İki özel düğme ile bir satır oluşturmak için çalışıyorum ve özel bir metin düzenleme. Salt metin içeriği kadar yer kaplıyor gereken düzenleme, ve iki düğme yatay satırda mevcut geri kalan alanı doldurmak için genişletmek gerekir. Bu gibi

| [#Button  #] [#Button--#] [et] |

Bu en fazla birkaç denemeden sonra aşırı karmaşık görünse de istediğimi elde edebilirim.

| [Button] [Button] [###ET###] |

<LinearLayout 
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal|center_vertical"
    android:layout_weight="1"
    >

    <LinearLayout 
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="center_horizontal|center_vertical"
        >
        <RelativeLayout 
            android:id="@ id/btn_plus_container" 
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content"
            >
            <ImageButton 
                android:layout_height="wrap_content"
                android:layout_width="fill_parent" 
                android:id="@ id/btn_plus" 
                android:background="@drawable/btn"
                android:layout_centerInParent="true"
                ></ImageButton>
            <TextView 
                android:textColor="#FAFAF4"
                android:id="@ id/tv_dice_plus" 
                android:text="@string/tv_plus" 
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                ></TextView>
        </RelativeLayout>
    </LinearLayout>
    <LinearLayout 
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="center_horizontal|center_vertical"
        >
        <RelativeLayout 
            android:id="@ id/btn_minus_container" 
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content"
            >
            <ImageButton 
                android:layout_height="wrap_content"
                android:layout_width="fill_parent" 
                android:id="@ id/btn_minus" 
                android:background="@drawable/btn"
                android:layout_centerInParent="true"
                ></ImageButton>
            <TextView 
                android:textColor="#FAFAF4"
                android:id="@ id/btn_minus" 
                android:text="@string/tv_minus" 
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                ></TextView>
        </RelativeLayout>
    </LinearLayout>
    <LinearLayout 
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="center_horizontal|center_vertical"
        >
        <EditText 
            android:textColor="#FAFAF4"
            android:text="@string/et_output" 
            android:id="@ id/et_output" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"
            android:inputType="number"
            android:selectAllOnFocus="true" 
            android:minWidth="50sp"         
            android:maxWidth="50sp"
            android:background="@drawable/tv_black_background3"
            android:textColorHighlight="#c30505"
            ></EditText>
    </LinearLayout>
</LinearLayout>

Anladığım kadarıyla ayar [android:layout_weight="2"] doğrusal düzenleri holding düğmeleri gerekir onları almak daha fazla oda daha metni Düzenle, ama ne yaparsan yap beni, yapma ikisini de yarı yarıya küçülür.

| [Btn] [Btn] [#####et#####] |

Hatta onları hatırlayamıyorum çok farklı kombinasyon denedim ve hiçbiri çalıştı.

CEVAP
13 ŞUBAT 2011, Pazar


Genişlik olarak fill_parent kullanıyorsunuz çünkü işe yaramıyor. Kilo kalan boş alanı dağıtmak için kullanılıryatoplam miktarı LinearLayout daha büyük olduğunda uzaya götürmek. Senin genişliklerini ayarlayın0dipçalışmak yerine.

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • GoldgenieOfficial

    GoldgenieOff

    23 Temmuz 2009
  • jat4011

    jat4011

    16 EKİM 2010
  • segtlim

    segtlim

    21 EKİM 2008