SORU
28 ŞUBAT 2013, PERŞEMBE


Nasıl (dikey) ekleyin yatay bir LinearLayout için bölücü?

Yatay doğrusal bir düzen için bir bölme eklemek için çalışıyorum ama hiçbir yerde alıyorum ben. Bölücü sadece göstermiyor. Android ile tam bir çaylağım.

Bu düzen benim XML:

<RelativeLayout 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=".MainActivity" >

    <LinearLayout 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@ id/llTopBar"
        android:orientation="horizontal"
        android:divider="#00ff00"
        android:dividerPadding="22dip"
        android:showDividers="middle"
       >

        <Button
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:text="asdf" />
            <Button
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:text="asdf"
             />

    </LinearLayout>

</RelativeLayout>

CEVAP
28 ŞUBAT 2013, PERŞEMBE


Tadına bakın, res/drawable klasöründe bir bölücü oluşturun:

vertical_divider_1.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">    
    <size android:width="1dip" />
    <solid android:color="#666666" />    
</shape> 

Ve bu gibi LinearLayout divider özniteliğini kullanın:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="48dp"
    android:orientation="horizontal"
    android:divider="@drawable/vertical_divider_1"
    android:dividerPadding="12dip"
    android:showDividers="middle"
    android:background="#ffffff" >

    <Button
        android:id="@ id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button" />
    <Button
        android:id="@ id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button" />

</LinearLayout>

Not:android:divider 3.0 (API level 11) veya daha yüksek Android mevcuttur.

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

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Cole Rolland

    Cole Rolland

    23 Kasım 2008
  • Max Lee

    Max Lee

    18 AĞUSTOS 2006
  • pjtoohot

    pjtoohot

    15 NİSAN 2008