I'am setting the text to TextView and EditText programmatically. but those widgets are not visible. If i take android:layout_marginTop="100dp" for Textview, then i'am able to see those widgets. Why so? Can you suggest me any other way. Thanks in advance.
*<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="@color/homepage_background">
<Scr开发者_JAVA技巧ollView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_gravity="center"
android:layout_weight="1">
<LinearLayout android:layout_width="fill_parent"
android:layout_gravity="center" android:gravity="center"
android:orientation="vertical" android:layout_height="wrap_content">
<!-- This Textview is not visible -->
<TextView android:layout_width="fill_parent" android:id="@+id/updateText"
android:layout_height="wrap_content" android:textColor="@color/homepage_labelText"
android:layout_gravity="center" android:gravity="center"
/>
<!-- This EditText box also not visible (only half) -->
<EditText android:id="@+id/previousText" android:textColor="@color/homepage_labelText"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:cursorVisible="false" android:layout_gravity="center"
android:layout_marginLeft="10dp" android:maxLines="2"
android:layout_marginRight="10dp" />
<TextView android:layout_width="fill_parent" android:id="@+id/text"
android:layout_height="wrap_content" android:textColor="@color/homepage_labelText" android:text="Complaint"
android:layout_gravity="center" android:gravity="center"
android:layout_marginTop="10dp" />
<EditText android:id="@+id/updateEditText" android:lines="5"
android:focusable="true" android:inputType="textMultiLine"
android:gravity="top" android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" android:textSize="15dp"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_gravity="center"
android:hint="Enter to update complaint info " />
</LinearLayout>
</ScrollView>
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent" android:layout_height="50dp"
android:gravity="center" android:background="@color/homepage_title_background"
android:layout_gravity="center">
<Button android:id="@+id/updateComplaintSubmitButton"
android:text=" Update " android:textColor="@color/homepage_labelText"
android:layout_width="wrap_content" android:layout_height="40dp" />
<Button android:id="@+id/updateComplaintCancelButton"
android:text=" Cancel " android:textColor="@color/homepage_labelText"
android:layout_marginLeft="30dp" android:layout_width="wrap_content"
android:layout_height="40dp" />
</LinearLayout>
</LinearLayout>*
I think I have the same problem and it comes from the gravity property of your TextView.. it is set to center. I don't know for sure why android is hiding the TextView in this case and I am trying to fix this as well
精彩评论