Rob
Rob

Reputation: 31

Content in textview not showing (Android Studio)

I'm using a grid layout to create 4 TextViews. Each of those will contain a number that was pressed by the user when creating a passcode. I'm just testing it out at the moment and I found that setting

android:text="33" //any random value

does absolutely nothing in showing the value on the preview window.

Here is my code:

<GridLayout
    android:layout_width="280dp"
    android:layout_height="200dp"
    android:paddingTop="75dp"
    android:orientation="horizontal"
    android:columnCount="4"
    android:layout_gravity="center"
    >

    <TextView
        android:id="@+id/firstNumberBox"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:layout_column="0"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:background="@drawable/pin_value_border"
        android:gravity="center"
        android:paddingTop="50dp"
        android:text="33"
        android:textColor="@color/whitec"
        android:textSize="16sp"
        />

pin_value_border.xml:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<stroke
    android:width="2dp"
    android:color="#ffffff" />
</shape>

Below is a picture showing my code and what I'm referring to with the problem:

a

Upvotes: 1

Views: 1624

Answers (2)

Amit pandey
Amit pandey

Reputation: 1195

in your xml you gieve the textView height 50 dp and you give top padding 50dp thats the reason it not show the text view remove the 50dp top paddding if you want to give padding make your android_layout_height=warap_content

Upvotes: 0

Dipankar Baghel
Dipankar Baghel

Reputation: 2039

I got your issue - just remove the android:paddingTop="50dp" from the text view or reduce the padding top. and text will be visible.

You are giving padding top equals to height thats why text is not visible.

Upvotes: 2

Related Questions