Reputation: 91
I am not able to view the TextView
in device and in emulator but it is there in preview. I am using android studio. I even try to add some other views instead of textView but I am still facing the same problem.
Did I miss something or do I need to make any change in the setting of android studio.
This problem started after I used the scrollView
.
The code which I am using is given below:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars = "vertical"
android:id="@+id/scroll">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".MainActivity"
tools:showIn="@layout/activity_main">
<!--THE BELOW TEXTVIEW IS NOT VISIBLE ON MY DEVICE BUT IT'S SHOWING IN PREVIEW -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Topping"
android:textAllCaps="true" />
<CheckBox
android:id="@+id/whipped_cream_checkbox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Whipped Cream"
android:textSize="16sp"
android:layout_marginTop="16dp"
android:paddingLeft="24dp"/>
<CheckBox
android:id="@+id/chocolate_checkbox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Chocolate"
android:textSize="16sp"
android:layout_marginTop="16dp"
android:paddingLeft="24dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Quantity"
android:layout_marginTop="16dp"
android:textAllCaps="true" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginTop="16dp"
android:onClick="increment"
android:text="+" />
<TextView
android:id="@+id/quantity_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:text="2"
android:textColor="#000000"
android:textSize="16sp" />
<Button
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginTop="16dp"
android:onClick="decrement"
android:text="-" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="ORDER SUMMARY"
android:textAllCaps="true" />
<TextView
android:id="@+id/order_summary_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="10"
android:textColor="#000000"
android:textSize="16sp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:onClick="submitOrder"
android:text="ORDER" />
Upvotes: 0
Views: 77
Reputation: 29
I tried checking the layout file .It worked for me as i found some of the end tags missing in the content provided by just adding them it worked .
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars = "vertical"
android:id="@+id/scroll">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity"
tools:showIn="@layout/activity_main">
<!--THE BELOW TEXTVIEW IS NOT VISIBLE ON MY DEVICE BUT IT'S SHOWING IN PREVIEW -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Topping"
android:textAllCaps="true" />
<CheckBox
android:id="@+id/whipped_cream_checkbox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Whipped Cream"
android:textSize="16sp"
android:layout_marginTop="16dp"
android:paddingLeft="24dp"/>
<CheckBox
android:id="@+id/chocolate_checkbox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Chocolate"
android:textSize="16sp"
android:layout_marginTop="16dp"
android:paddingLeft="24dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Quantity"
android:layout_marginTop="16dp"
android:textAllCaps="true" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginTop="16dp"
android:onClick="increment"
android:text="+" />
<TextView
android:id="@+id/quantity_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:text="2"
android:textColor="#000000"
android:textSize="16sp" />
<Button
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginTop="16dp"
android:onClick="decrement"
android:text="-" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="ORDER SUMMARY"
android:textAllCaps="true" />
<TextView
android:id="@+id/order_summary_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="10"
android:textColor="#000000"
android:textSize="16sp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:onClick="submitOrder"
android:text="ORDER" />
</LinearLayout>
</ScrollView>
Upvotes: 1
Reputation: 29
Change the color of the textview because the some API default color is white.
Set the textview color as android:textColor="@color/black"
Upvotes: 0