как оформить стол в андроиде - PullRequest
0 голосов
/ 22 июня 2011

в моем приложении мне нужно создать, как показано на следующем рисунке enter image description here

Я использую макет таблицы для этого, но я получаю следующее:

TextViewTextViewTextView .....

mycode:

   ....... 
<TableLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/tableLayout1">
<TableRow android:id="@+id/tableRow1" android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <TextView android:layout_width="fill_parent" android:text="Your State"
       android:layout_gravity="left" android:id="@+id/textView1"
       android:layout_height="wrap_content">
    </TextView>
    <TextView android:layout_width="wrap_content" android:text="Your State"
       android:layout_gravity="left" android:id="@+id/textView1"
       android:layout_height="wrap_content">
    </TextView>
</TableRow>
     .........

мой дизайн не показан на изображении выше.Я не знаю, как разработать точное изображение выше.пожалуйста, помогите мне

Ответы [ 5 ]

3 голосов
/ 30 мая 2014

XML-файл:

<?xml version="1.0" encoding="utf-8"? >
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="1">

<TableRow android:layout_width="match_parent"
    android:weightSum="1"
    android:layout_height="wrap_content">
    <TextView
        android:background="@drawable/shape_edittext"
     android:layout_weight="0.2"
     android:layout_width="0dp"
     android:layout_height="match_parent"
        android:text="Save As..."
        android:padding="3dip" />

    <TextView
        android:background="@drawable/shape_edittext"
        android:layout_weight="0.8"
     android:layout_width="0dp"

        android:padding="3dip"
        android:text="Ctrl-Oda asd dfgd df gdfgd gdf dfg dfgd df g  d a asda dsadasd ada das sad adas  das dsa dsda asd asd  sad a dad" />


</TableRow>


</TableLayout>

=============================

нарисованный файл

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"    
android:shape="rectangle">
<gradient
    android:startColor="#FFFFFF"
    android:endColor="#FFFFFF"
    android:angle="45"/>
<padding android:left="8dp"
    android:top="8dp"
    android:right="8dp"
    android:bottom="8dp" />
<corners android:radius="0dp" />
<stroke android:width="1dp" android:color="#FF0000"/>
<solid android:color="@android:color/darker_gray"/>
</shape>
1 голос
/ 22 июня 2011

У вас должно быть шесть таблиц нестабильного макета, и каждая таблица должна состоять из четырех текстовых представлений.

См. Пример кода

<?xml version="1.0" encoding="utf-8"?>
<TableLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

    <TableRow>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text=""
            android:textColor="#ffffff"
            android:textStyle="bold" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Password:"
            android:textColor="#ffffff"
            android:textStyle="bold" />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Pas111"
            android:textColor="#ffffff"
            android:textStyle="bold" />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Pas111"
            android:textColor="#ffffff"
            android:textStyle="bold" />
    </TableRow>

    <TableRow>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Password"
            android:textColor="#ffffff"
            android:textStyle="bold" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Pas111"
            android:textColor="#ffffff"
            android:textStyle="bold" />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Pas111"
            android:textColor="#ffffff"
            android:textStyle="bold" />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Pas111"
            android:textColor="#ffffff"
            android:textStyle="bold" />
    </TableRow>
</TableLayout>
0 голосов
/ 29 июля 2015

Создание таблицы с использованием HTML / CSS.Стол будет сделан легко и намного красивее.Используйте WebView для доступа к HTML-файлу таблицы.Сохраните HTML-файл в папке активов.Для получения более подробной информации Google, как реализовать HTML-файл в Android.

0 голосов
/ 22 июня 2011
  android:background="@android:drawable/btn_default_small"

поместите этот тег в textViews и tableLayout у вас есть .. в xml .. вы можете указать другие значения, такие как "editbox_background" и т.д ..

0 голосов
/ 22 июня 2011

попробуйте поэкспериментировать с "android: stretchColumns"

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...