Android: Mettre un diviseur vertical/ligne de séparation entre textviews dans un linéaire horizontale disposition imbriquée dans les linéaires verticaux de mise en page?
Pour android contenu de vue, j'ai une verticale linearlayout avec certains textviews qui ont certaines lignes de fracture et séparés les éléments verticaux, cela fonctionne bien et le xml est ci-dessous.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="@string/A" />
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="@string/B" />
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="@string/C" />
</LinearLayout>
<View
android:background="#ffffff"
android:layout_width = "fill_parent"
android:layout_height="1dip"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/D" />
<View
android:background="#ffffff"
android:layout_width = "fill_parent"
android:layout_height="1dip" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/E" />
</LinearLayout>
Maintenant, je veux ajouter une verticale de la ligne de séparation entre l'placée horizontalement texte dans le imbriqués textviews avec des cordes A/B/C. Quand j'essaie de le faire par l'ajout de la codé en dur largeur de Vue, la ligne s'étend sur la totalité de la hauteur du parent linéaire de la mise en page.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="@string/A" />
<!--the vertical line separator-->
<View
android:background="#ffffff"
android:layout_width = "1dip"
android:layout_height="fill_parent" />
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="@string/B" />
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="@string/C" />
</LinearLayout>
<View
android:background="#ffffff"
android:layout_width = "fill_parent"
android:layout_height="1dip"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/D" />
<View
android:background="#ffffff"
android:layout_width = "fill_parent"
android:layout_height="1dip" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/E" />
</LinearLayout>
Pour ce séparateur vertical vue j'ai essayé d'utiliser android:layout_height="wrap_content"/>
à la place, mais le même résultat est présenté.
Est-il un moyen d'avoir un séparateur vertical ici où la hauteur est conservé avec l'introduction d'une ligne verticale pour séparer textviews? Ou doit-je choisir une mise en page différente?
OriginalL'auteur Vass | 2012-10-10
Vous devez vous connecter pour publier un commentaire.
Une autre option pourrait être d'inclure
android:layout_margin
(ou séparélayout_marginTop
etlayout_marginBottom
) pour créer un espace entre le haut et le bas de la ligne verticale et l'horizontale bords de laLinearLayout.
Autre que cela, j'ai peut-être essayer un
RelativeLayout,
et votre ligne verticale vue ajustées pour aligner le haut et le bas de l'un des adjacenteTextViews.
OriginalL'auteur Mark Semsel
Vous devez donner une correction de la hauteur à votre LinearLayout ou votre Verticale de l'élément de séparation
OriginalL'auteur maninder singh