查看走出屏幕:android

时间:2018-01-06 01:30:25

标签: android android-layout android-tablelayout drawerlayout programmatically

以下是我的布局视图(activity_home.xml)。



<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:id="@+id/drawerLayout">

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">


        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/container"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="25dp"
                android:orientation="horizontal" >

                <TableLayout
                    android:id = "@+id/TableLayout02"
                    android:layout_width = "match_parent"
                    android:layout_height = "150dp"
                    android:layout_gravity="center_horizontal">
                   
                </TableLayout >
            </LinearLayout>

        </LinearLayout>
    </RelativeLayout>

    <android.support.design.widget.NavigationView
        android:id="@+id/menuBar"
        android:background="#E8E8E8"
        app:insetForeground="#4000"
        app:itemTextColor="#585858"
        app:itemIconTint="#700000"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        app:headerLayout="@layout/navigation_header"
        app:menu="@menu/navigation_menu"
        android:layout_gravity="start">
    </android.support.design.widget.NavigationView>

</android.support.v4.widget.DrawerLayout>
&#13;
&#13;
&#13;

我正在尝试填写表格,如下所示。

&#13;
&#13;
TableLayout table = (TableLayout)findViewById(R.id.TableLayout02);
        TextView[] textviews = new TextView[6];
        TableRow rowtext = new TableRow(context);

        for(int i=0;i<6;i++){
             textviews[i] = new Button(rowtext.getContext(), null);
             textviews[i].setPadding(0, -5, 0, 10);
             textviews[i].setTextSize(20);
             applyFilter(textviews[i], BlurMaskFilter.Blur.OUTER);

            if(i==0) {
                 textviews[i].setGravity(Gravity.CENTER_HORIZONTAL);
                 textviews[i].setText("Text0");
             }
             else if (i==1){
                 textviews[i].setGravity(Gravity.RIGHT);
                 textviews[i].setText("Text1");
             }
             else if (i==2){
                 textviews[i].setGravity(Gravity.LEFT);
                 textviews[i].setText("Text2");
             }
             else if (i==3){
                 textviews[i].setGravity(Gravity.RIGHT);
                 textviews[i].setText("Text3");
             }
             else if (i==4){
                 textviews[i].setGravity(Gravity.LEFT);
                 textviews[i].setText("Text4");
             }
             else if (i==5){
                 textviews[i].setGravity(Gravity.RIGHT);
                 textviews[i].setText("Text5");
             }
           
            rowtext.addView(textviews[i], new TableRow.LayoutParams(0, TableRow.LayoutParams.WRAP_CONTENT, 1f));
        }
        table.addView(rowtext);
&#13;
&#13;
&#13;

在android 4.4.4设备上,视图离开屏幕(右侧),如下所示。

| -------------- Text0 -------------- | -------------- Text1- ------------- |

在运行更高版本android的设备上,它按预期工作(如下所示)。

| --Text0-- | ----文本1 |文本2 ---- | ----文本3 |文本4 ---- | ---- Text5 |

可能是什么问题?请帮忙。

0 个答案:

没有答案