Android计量单位有什么区别?
user-interface android units-of-measurement dimension android-layout
下面是我的表格代码.我的屏幕看起来像这样http://imgur.com/dFP298o但我想让它看起来像这样http://imgur.com/YuYJiJx.如何在每行和表格布局周围添加边框?
<TableLayout
android:id="@+id/table2"
android:layout_width="fill_parent"
android:layout_below="@+id/test_button_text23"
android:layout_marginLeft="45dp"
android:layout_marginBottom="25dp"
android:layout_marginRight="45dp"
android:layout_height="fill_parent"
android:stretchColumns="*" >
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:gravity="left"
android:text="Quantity"
android:textStyle="bold" />
<TextView
android:gravity="center"
android:textStyle="bold"
android:text="Item" />
</TableRow>
</TableLayout>
Run Code Online (Sandbox Code Playgroud)
<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/localTime"
android:textColor="#000000"
android:gravity="left" />
<TextView
android:id="@+id/apprentTemp"
android:textColor="#000000"
android:gravity="center" />
</TableRow>
Run Code Online (Sandbox Code Playgroud)
View row = getLayoutInflater().inflate(R.layout.rows, null);
((TextView) row.findViewById(R.id.localTime)).setText(item.getString("Item"));
((TextView) row.findViewById(R.id.apprentTemp)).setText(item.getString("Quantity"));
Run Code Online (Sandbox Code Playgroud) 我正在显示一个表格布局,因为我想要在表格中的行之间分隔线.也可以在表格布局中进行列方式分离.请帮助我.
以下是我的xml表格布局:
<?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="wrap_content"
android:orientation="vertical"
android:paddingBottom="6dip"
android:paddingTop="4dip">
<TableLayout
android:id="@+id/tablelayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingRight="2dip">
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Income"></TextView>
<TextView
android:layout_width="150px"
android:layout_height="wrap_content"
android:layout_marginLeft="150dp"
android:text="Expense"></TextView>
</TableRow>
<TableRow android:layout_marginTop="30px">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Household:"></TextView>
<TextView
android:id="@+id/text50"
android:layout_width="150px"
android:layout_height="wrap_content"
android:text="Household:"></TextView>
</TableRow>
<TableRow android:layout_marginTop="40px">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_span="2"
android:text="Travel:"></TextView>
<TextView
android:id="@+id/text51"
android:layout_width="150px"
android:layout_height="wrap_content"
android:layout_marginLeft="-250dp"
android:text="Travel"></TextView>
</TableRow>
<TableRow android:layout_marginTop="40px">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_span="2"
android:text="Education:"></TextView>
<TextView
android:id="@+id/text52"
android:layout_width="150px"
android:layout_height="wrap_content"
android:layout_marginLeft="-250dp"
android:text="Education"></TextView>
</TableRow>
</TableLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) 我想在表格行内绘制一条垂直和水平线.
我无法附上图片
我尝试TextView在表格行中绘制线条但下面没有正确连接的线条是我的xml和样式
<TableLayout
android:id="@+id/traningprogram_tabla_monday"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stretchColumns="0,1,2,3"
>
<TableRow
android:id="@+id/traningprogram_tableRow_mondayHeading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/traningprogram_textView_mondayheadingWeek"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"
android:padding="5dp"
android:textSize="12dp"
android:text="TextView" />
<TextView
android:id="@+id/traningprogram_textView_mondeyheadingWeekName"
android:layout_width="0dp"
android:layout_height="25dp"
android:layout_weight="1"
android:padding="5dp"
android:textSize="12dp"
android:text="TextView" />
</TableRow>
<TableRow android:id="@+id/traningprogram_tableRow_workspeed" android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView
android:id="@+id/traningprogram_textView_workspeed"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="25dp"
android:background="@drawable/cell_shape"
android:padding="5dp"
android:text="@string/workspeed"
android:textSize="12dp"
></TextView>
<TextView
android:background="@drawable/cell_shape"
android:padding="5dp"
android:id="@+id/traningprogram_textView_workspeedvalue"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="25dp"
android:textSize="12dp"
android:text="TextView"></TextView>
</TableRow>
<TableRow android:id="@+id/traningprogram_tableRow_recoveryspeed" android:layout_width="match_parent" android:layout_height="wrap_content">
<TextView
android:id="@+id/traningprogram__textView_recoveryspeed"
android:layout_width="0dip"
android:layout_height="25dp"
android:layout_weight="1"
android:background="@drawable/cell_shape"
android:padding="5dp"
android:textSize="12dp"
android:text="@string/recoveryspeed" ></TextView>
<TextView
android:background="@drawable/cell_shape" …Run Code Online (Sandbox Code Playgroud) 如何实现如下屏幕截图(1预期结果,2实际结果).正如你可以看到每个项目都有边框,它对于某些项目来说就像是左边和底部,对于某些项目来说,它是正确的和底部的.我创建了视图使用TableLayout但现在我不知道如何将边框应用于每一行和项目.我的问题是:
这是正确的方式TableLayout或应该使用GridView?
在预期的结果中,你可以看到边框是用渐变完成的,它只是淡化,所以任何人都可以为我提供可绘制的代码.
TableLayout代码:
<TableLayout
android:id="@+id/layout_pinlock_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/layout_pinlock_header"
android:layout_marginTop="@dimen/padding_15dp"
android:gravity="center_vertical"
android:padding="@dimen/padding_10dp"
android:stretchColumns="*" >
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/Tv_pinLock_01"
style="@style/TextViewMyTheme"
android:text="1" />
<TextView
android:id="@+id/Tv_pinLock_02"
style="@style/TextViewMyTheme"
android:text="2" />
<TextView
android:id="@+id/Tv_pinLock_03"
style="@style/TextViewMyTheme"
android:text="3" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/Tv_pinLock_04"
style="@style/TextViewMyTheme"
android:text="4" />
<TextView
android:id="@+id/Tv_pinLock_05"
style="@style/TextViewMyTheme"
android:text="5" />
<TextView
android:id="@+id/Tv_pinLock_06"
style="@style/TextViewMyTheme"
android:text="6" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/padding_10dp"
android:layout_marginBottom="@dimen/padding_10dp">
<TextView
android:id="@+id/Tv_pinLock_07"
style="@style/TextViewMyTheme"
android:text="7" />
<TextView
android:id="@+id/Tv_pinLock_08"
style="@style/TextViewMyTheme"
android:text="8" />
<TextView
android:id="@+id/Tv_pinLock_09"
style="@style/TextViewMyTheme"
android:text="9" />
</TableRow>
<TableRow …Run Code Online (Sandbox Code Playgroud) 我开始使用android,我想在这个答案中描述为细胞添加边框.所以我创建了我的cell_background.xml文件,Eclipse在其中创建res\drawable并包含
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape= "rectangle" >
<solid android:color="#000"/>
<stroke android:width="1dp" android:color="#ff9"/>
</shape>
Run Code Online (Sandbox Code Playgroud)
看过drawable文件夹有几个问题后,我将其逐字复制到res\drawable-*dpi目录中
现在,我的应用程序崩溃在以下行
Drawable drawable = Resources.getSystem().getDrawable(R.drawable.cell_background);
Run Code Online (Sandbox Code Playgroud)
有这个例外
12-16 14:26:28.624: E/AndroidRuntime(533): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f020000
Run Code Online (Sandbox Code Playgroud)
项目和模拟器都设置为v3.0
有任何想法吗?我已经清理并重建了该项目,但它仍然崩溃了.