标签: android-tablelayout

在android中创建一个chatView布局

我正在创建一个聊天应用程序,我正在考虑如何创建实际的聊天视图.

我已经有聊天窗口本身的布局,但我正在考虑如何实现聊天消息.

我正在考虑创建一个TableLayout,每一行将是用户图像和聊天消息(或泡沫或什么不是).

有没有人知道如何设计和创建这些行?

这就是我现在所做的:

<?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:background="@android:color/background_light"
    android:orientation="vertical"
    android:weightSum="10" >

    <ScrollView
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_weight="1" >

        <TableLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:stretchColumns="1" >

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

                <!-- insert chat message here !-->

            </TableRow>

            <View
                android:layout_height="2dip"
                android:background="#000" />

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

                 <!-- next chat message --!>

            </TableRow>
        </TableLayout>
    </ScrollView>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:layout_weight="9"
        android:orientation="horizontal" >

        <EditText
            android:id="@+id/chatLine"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:hint="Say:"
            android:imeOptions="actionSend"
            android:singleLine="true" />
    </LinearLayout>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)


而我正在努力实现这一目标 所需的聊天视图

android android-custom-view android-layout android-tablelayout

19
推荐指数
4
解决办法
8万
查看次数

如何在点击时突出显示表格行?

作为我的项目要求,我必须在onClick上突出显示表格行.有办法做到这一点吗?或者请建议我替代方案?

android highlight android-tablelayout

17
推荐指数
3
解决办法
2万
查看次数

如何在Android中使用多列创建表格?

我想在android中创建一个包含多列的表.我看到的大多数例子都是2列.(我是Java和Android的新手.)我需要3-4列,我应该能够在表中动态添加行.任何人都可以提供示例代码.(我在win 7中使用eclipse)

java xml android android-tablelayout

16
推荐指数
1
解决办法
6万
查看次数

如何在TableLayout周围添加边框?

下面是我的表格代码.我的屏幕看起来像这样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)

android android-tablelayout

16
推荐指数
1
解决办法
5万
查看次数

机器人:stretchColumns

我想我在这里找不到一个好的解释.那么有人可以告诉我android:stretchColumns实际上做了什么吗?我在我的桌子上有它并尝试了几个不同的值,但似乎无法弄清楚它在做什么.

抱歉这个愚蠢的问题!

android android-tablelayout

14
推荐指数
1
解决办法
1万
查看次数

14
推荐指数
1
解决办法
2万
查看次数

Android响应式布局

我正在构建应用程序(计算器).我使用带有按钮的表格布局.它在三星Galaxy II的屏幕上看起来很完美,但在大屏幕上看起来非常糟糕.按钮高度很小.如何在更大的屏幕上拉伸按钮?

布局XML如下:

<ScrollView xmlns:android="http://schemas.an
    xmlns:tools="http://schemas.android.com/
    android:layout_width="match_parent"     
    android:layout_height="match_parent"    
    android:gravity="right"                 
    android:paddingBottom="@dimen/activity_v
    android:paddingLeft="@dimen/activity_hor
    android:paddingRight="@dimen/activity_ho
    android:paddingTop="@dimen/activity_vert
    tools:context=".MainActivity" >         


<TableLayout                                
    android:layout_width="match_parent"     
    android:layout_height="match_parent"    
    android:gravity="right"                 
    >                                       



    <TableRow                               
        android:id="@+id/tableRow1"         
        android:layout_width="match_parent" 
        android:layout_height="0dp">        

        <Button                             
            android:id="@+id/Button01"      
            android:layout_width="0dp"      
            android:layout_weight="0.33"    
            android:layout_height="fill_pare
            android:text="@string/button_1" 
            android:visibility="visible" /> 

        <Button                             
            android:id="@+id/Button02"      
            android:layout_width="0dp"      
            android:layout_weight="0.34"    
            android:layout_height="fill_pare
            android:text="@string/button_2" 

        <Button                             
            android:id="@+id/Button03"      
            android:layout_width="0dp"      
            android:layout_weight="0.33"    
            android:layout_height="fill_pare
            android:text="@string/button_3" 

    </TableRow>                             

    <TableRow                               
        android:id="@+id/tableRow2"         
        android:layout_width="match_parent" 
        android:layout_height="0dp" >       

    <Button                                 
        android:id="@+id/Button04"          
        android:layout_width="0dp"          
            android:layout_weight="0.33"    
        android:layout_height="fill_parent" 
        android:text="@string/button_4" />  

    <Button                                 
        android:id="@+id/Button05"          
        android:layout_width="0dp"          
        android:layout_weight="0.34"        
        android:layout_height="fill_parent" 
        android:text="@string/button_5" />  

    <Button                                 
        android:id="@+id/Button06"          
        android:layout_width="0dp"          
        android:layout_weight="0.33"        
        android:layout_height="fill_parent" 
        android:text="@string/button_6" />  

     </TableRow>                            

    <TableRow                               
        android:id="@+id/tableRow3"         
        android:layout_width="match_parent" 
        android:layout_height="0dp" >       

        <Button                             
            android:id="@+id/Button07"      
            android:layout_width="0dp" …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-resolution android-tablelayout

14
推荐指数
1
解决办法
3万
查看次数

Android TableLayout标题行

好的,所以我得到了这个TableLayout,以及它的全部数据 - 以编程方式添加了所有行.我在Horizo​​ntalScrollView中有TableLayout,而Horizo​​ntalScrollView又在ScrollView中 - 这使我可以水平和垂直滚动.我现在要做的是添加一个不会滚动的标题行.我试过移动东西,以便我的两个滚动视图实际上都在TableLayout中,并将TableRows添加到Horizo​​ntalScrollView; 我希望能够在滚动视图之外添加标题行.

我能想到的另一件事就是为标题行设置了第二个表格布局,但是让列排成一行似乎很难.有任何想法吗?

android android-layout android-tablelayout

13
推荐指数
2
解决办法
4万
查看次数

在TableLayout的列之间添加空格

我有一个TableLayout,我动态添加TableRows.在每个TableRow中,我添加一个Button.

我只是想在我的列之间添加一些空格(这是我的按钮)但我无法弄清楚如何...我试图改变所有可能的边距但它不起作用:(所以也许我做了我的代码中的错误,我从XML文件中膨胀它们:

private void createButtons(final CategoryBean parentCategory) {
    final List<CategoryBean> categoryList = parentCategory.getCategoryList();
    title.setText(parentCategory.getTitle());
    // TODO à revoir
    int i = 0;
    TableRow tr = null;
    Set<TableRow> trList = new LinkedHashSet<TableRow>();
    for (final CategoryBean category : categoryList) {

        TextView button = (TextView) inflater.inflate(R.layout.button_table_row_category, null);
        button.setText(category.getTitle());
        if (i % 2 == 0) {
            tr = (TableRow) inflater.inflate(R.layout.table_row_category, null);
            tr.addView(button);
        } else {
            tr.addView(button);
        }

        trList.add(tr);

        button.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                CategoryBean firstChild = category.getCategoryList() != null && …
Run Code Online (Sandbox Code Playgroud)

android divider android-tablelayout

13
推荐指数
2
解决办法
4万
查看次数

如何在Android中从XML扩展视图?

我正在创建一个tableLayout [以XML格式给出]

添加表行[以XML格式创建并在Java中膨胀]

还在表格中添加2个textview [以XML格式创建并在JAVA中进行膨胀]

我只能获得背景和文本颜色,但不能获得宽度,高度和边距等布局属性来获取表格视图.

user-interface android view android-inflate android-tablelayout

13
推荐指数
2
解决办法
3万
查看次数