0

I'm displaying the data in the pop-up in tabular format. But some data in the row is not displaying. I'm not able to see the textview only. Below is my layout.

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="50dp"
    android:layout_width="fill_parent"
>

    <TableRow
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <TextView
        android:id="@+id/pageTitle"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:textColor="#000000" />

    </TableRow>

    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center_vertical"
            android:gravity="center_vertical">
            <View
                android:id="@+id/vwVerticalColourBar"
                android:layout_width="5dp"
                android:layout_height="match_parent"
                android:layout_gravity="center_vertical"
                android:background="@color/grey"
                android:gravity="center_vertical" />
            <TextView
                android:id="@+id/tvVisitTime"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical"
                android:gravity="center_vertical"
                android:paddingLeft="5dp"
                android:paddingRight="5dp"
                android:textSize="16sp" />
            <View
                android:layout_width="1dp"
                android:layout_height="match_parent"
                android:layout_marginBottom="8dp"
                android:layout_marginTop="8dp"
                android:background="#EDEDED" />

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:padding="5dip" >

                <TextView
                    android:id="@+id/tvVisitStoreName"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_vertical"
                    android:gravity="center_vertical"
                    android:textColor="#000000"
                    android:textSize="16sp" />

                <TextView
                    android:id="@+id/tvVisitStoreAddress"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_vertical"
                    android:gravity="center_vertical"
                    android:textColor="#333333"
                    android:textSize="12dp"
                    />
            </LinearLayout>

        </LinearLayout>

    </TableRow>

    <TableRow
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="@android:color/darker_gray"/>

    </TableRow>
</TableLayout>

In the above layout, the tvVisitStoreAddress textview is not at displaying. Please find the screen shot as below. Is this regarding the size of the row or something else.

Current

But actually, it should display as below. Please help me in this regard.

Actual

coders
  • 719
  • 1
  • 11
  • 35

3 Answers3

1

The first LinearLayout in the TableRow with the TextViews does not have it's orientation property set.

Just put android:orientation="vertical"

AnxGotta
  • 1,006
  • 7
  • 28
  • Thanks for reply Anxgotta, i will try and let you know – coders Oct 16 '15 at 11:13
  • kishore jethava also made a good point that I didn't notice. You are restricting the height of the TableLayout. Make sure that leaves enough space for the contents of the TableRows. Try wrap_content first to get the format of the layout correct, then shrink it if you like and watch the results. – AnxGotta Oct 16 '15 at 11:15
  • Ok, you mean to say give table layout height as wrap content first, then shrink it accordinly? – coders Oct 16 '15 at 11:17
  • That's what I mean, yes. Apologies if I was unclear =) Start with the TableLayout height as 'wrap_content' just to eliminate it as a possible issue. Then get your TableRows looking correct. Then go back to adjusting the TableLayout height to your liking if needed. – AnxGotta Oct 16 '15 at 11:19
  • No problem, ok. In this case let my table layout be wrap content only. Because, the data inside popup may increase. Thanks for the help. It worked. – coders Oct 16 '15 at 11:22
  • And also, one more thing i wanted to ask you. The date in the above picture, is actually a title, how to increase the size of that particular and make it center alignment. Could you shed me some lights in this regard AnxGotta – coders Oct 16 '15 at 11:24
  • I'm glad it helped. To get that title Text view text larger and centered you could do the following: In the TextView xml, simply add android:gravity="center" and then change android:textSize="#sp" where # is the number of the text size... 16 or something. You already have the TextVIew width as "fill_parent" so you just need to center the text using the android:gravity xml property. (UseChat if you need more help) – AnxGotta Oct 16 '15 at 11:33
  • Ok AnxGotta, thanks a lot. I will try as you suggested. If i require any more details, i will ping you. – coders Oct 16 '15 at 16:29
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/92526/discussion-between-coders-and-anxgotta). – coders Oct 16 '15 at 16:29
1

Because you have set fix height of TableLayout

change TableLayout height android:layout_height="50dp" to android:layout_height="100dp"

Kishore Jethava
  • 6,666
  • 5
  • 35
  • 51
1

Actually TableLayout height creates this problem . Just increase your android:layout_height

How Do

You can set android:layout_height as dynamically . You can use DisplayMetrics .And set Height respect to Device Height .

Detect 7 inch and 10 inch tablet programmatically

Community
  • 1
  • 1
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198