/ / android: comment afficher la bordure de TableLayout - android, tablelayout

android: comment afficher la bordure de TableLayout - android, tablelayout

comment puis-je mettre en évidence la bordure de la mise en page ... im en utilisant roundshape.xml qui a une forme comme arrière-plan, il doit y avoir un moyen de donner la bordure autour de votre tablelayout ...

roundshape.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >

<corners android:radius="5dip" />

<gradient
android:angle="270"
android:endColor="@color/WhiteSmoke"
android:startColor="@color/WhiteSmoke"
android:type="linear" />

</shape>

WhiteSmoke = # F5F5F5

main.xml

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

<TableLayout
android:layout_width="400dp"
android:layout_height="400dp"
android:background="@drawable/roundshape"
>

<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >

</TableRow>

<TableRow
android:id="@+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</TableRow>

<TableRow
android:id="@+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</TableRow>

<TableRow
android:id="@+id/tableRow4"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</TableRow>
</TableLayout>

</LinearLayout>

Réponses:

2 pour la réponse № 1

je pense que cela pourrait vous aider .. passer par le code u va comprendre l'astuce

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

<TableLayout
android:layout_width="400dp"
android:layout_height="400dp"
android:background="@drawable/roundshape" >

<TableRow
android:layout_width="fill_parent"
android:layout_height="1px"
android:background="#ff9" >

<TextView
android:layout_width="fill_parent"
android:layout_height="1px"
android:text="" />
</TableRow>

<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >

<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="this is amazing" />
</TableRow>

<TableRow
android:layout_width="fill_parent"
android:layout_height="1px"
android:background="#ff9" >

<TextView
android:layout_width="fill_parent"
android:layout_height="1px"
android:text="" />
</TableRow>

<TableRow
android:id="@+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >

<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="this is amazing" />
</TableRow>

<TableRow
android:layout_width="fill_parent"
android:layout_height="1px"
android:background="#ff9" >

<TextView
android:layout_width="fill_parent"
android:layout_height="1px"
android:text="" />
</TableRow>

<TableRow
android:id="@+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >

<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="this is amazing" />
</TableRow>

<TableRow
android:layout_width="fill_parent"
android:layout_height="1px"
android:background="#ff9" >

<TextView
android:layout_width="fill_parent"
android:layout_height="1px"
android:text="" />
</TableRow>

<TableRow
android:id="@+id/tableRow4"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >

<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="this is amazing" />
</TableRow>

<TableRow
android:layout_width="fill_parent"
android:layout_height="1px"
android:background="#ff9" >

<TextView
android:layout_width="fill_parent"
android:layout_height="1px"
android:text="" />
</TableRow>
</TableLayout>

</LinearLayout>

0 pour la réponse № 2

Il y a déjà un article très similaire à ce sujet ici.

De David Jesse

Ma solution à ce problème est de mettre un xmlressource utilisable sur le champ de fond de chaque cellule. De cette manière, vous pouvez définir un forme avec la bordure que vous souhaitez pour toutes les cellules. Le seul inconvénient est que les bordures des cellules extrêmes ont la moitié de la largeur du d'autres mais ce n'est pas un problème si votre table remplit tout l'écran.

Voici la référence à cette ressource.