Android Studio - TextView not showing in design view layout
There is a bug in latest sdk 28 ,
Change the compileSdkVersion 27
targetSdkVersion 27
and
implementation 'com.android.support:appcompat-v7:27.1.1'
Update:
This is said to fix problem but I did not test it yet
In styles.xml change the parent theme for your app to Base.Theme.AppCompat
instead of Theme.AppCompat
TextView not showing even I can see it on design and other views showing
You must use android:text="@string/sort"
instead of tools:text="@string/sort"
in your TextView
According to docs
You can insert sample data in your layout preview by using the tools: prefix instead of android: with any attribute from the Android framework. This is useful when the attribute's value isn't populated until runtime but you want to see the effect beforehand, in the layout preview.
For example, if the android:text attribute value is set at runtime or you want to see the layout with a value different than the default, you can add tools:text to specify some text for the layout preview only.
TextView is not showing in layout
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".frontScreen">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/colorAccent"
android:gravity="center"
android:orientation="horizontal"
android:padding="@dimen/activity_horizontal_margin">
<Button
android:id="@+id/plan1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:ignore="ButtonStyle" />
<Button
android:id="@+id/plan2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:ignore="ButtonStyle" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorAccent"
android:gravity="center"
android:orientation="horizontal"
android:padding="@dimen/activity_horizontal_margin">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="plan"
android:shadowColor="@color/colorPrimary"
android:textColor="@color/colorPrimary"
android:textSize="30sp"
android:shadowRadius="2"
android:gravity="center_horizontal"
android:shadowDx="1"
android:shadowDy="1"
/>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
hope this helps. But for better working you need to take relativelayout and linearlayout in single layout. feel free to ask if this doesn't works
EDIT:
If you need this in a single view you can try
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorAccent"
android:orientation="horizontal"
android:padding="@dimen/activity_horizontal_margin">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="plan"
android:shadowColor="@color/colorPrimary"
android:textColor="@color/colorPrimary"
android:textSize="30sp"
android:shadowRadius="2"
android:layout_alignParentTop="true"
android:gravity="center_horizontal"
android:shadowDx="1"
android:shadowDy="1" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/colorAccent"
android:gravity="center"
android:orientation="horizontal"
android:layout_centerInParent="true"
android:padding="@dimen/activity_horizontal_margin">
<Button
android:id="@+id/plan1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:ignore="ButtonStyle" />
<Button
android:id="@+id/plan2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:ignore="ButtonStyle" />
</LinearLayout>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
Content in textview not showing (Android Studio)
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.
TextView showing on design preview, but not in actual Android app
Found the issue. Switching android:text="You're currently logged in"
to android:text="You\'re currently logged in"
fixed it. So I guess Android requires escaping single quotes when setting the text in XML?
Found by using the layout inspector tool, which showed mText
as having no value
Textview not showing inside LinearLayout
Change width of text view to wrap content and replace tool:text to android:text
<TextView
android:id="@+id/products_row_item_price_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:textSize="20sp"
android:textStyle="bold"
android:text="$999.90" />
For answer second :
Use view before end of parent linear layout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="@color/white"
android:orientation="horizontal"
android:padding="20dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation = "vertical">
<ImageView
android:id="@+id/products_row_item_product_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_launcher" />
<TextView
android:id="@+id/products_row_item_product_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/fragment_marketplace_products_row_item_product_title"
android:textSize="17sp"
android:textStyle="bold" />
<TextView
android:id="@+id/products_row_item_description_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/products_row_item_product_description" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/very_light_grey"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/products_row_item_price_text_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:textSize="20sp"
android:textStyle="bold"
tools:text="$999.90" />
<ImageView
android:id="@+id/products_row_item_heart_image_view"
android:layout_width="27dp"
android:layout_height="27dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:scaleType="fitXY"
android:src="@drawable/like_heart" />
<TextView
android:id="@+id/products_row_item_likes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end"
android:text="@string/fragment_marketplace_products_row_item_likes"
android:textSize="20sp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/very_light_grey"/>
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="match"
android:background="@color/very_light_grey"/>
</LinearLayout>
Android Studio 3.1 design preview not showing anything (buttons, text, etc.)
*** Right Click on the Component, Then go to Constraint Layout and click Infer Constraints
Or
*** Replace Constraint Layout with a Relative Layout
UPDATE
Go to res/values/styles.xml file...
on line 4, its always...
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
Change this with
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
Related Topics
Remove Green Border Around Android Application
How to Open Draw Overlay Permission Popup in Miui
Android Studio - Xml Editor Autocomplete Not Working With Support Libraries
Prevent Screen Rotation on Android
Link Should Be Open in Same Web View in Android
Android Textview Text Not Getting Wrapped
Socket.Io Client Getting Connected Disconnected Repeatedly
Retrofit 2.0 - How to Get Response Body for 400 Bad Request Error
How to Add/Remove Object in Recyclerview Using Arraylist in Android
How to Reduce the Gap Between Tab Layout Text and Its Indicator
How to Set Value for Each Item Button Increase and Decrease Click and Set That Value in Text View
Android Set Height and Width of Custom View Programmatically
How to Figure Out Which Sim Received Sms in Dual Sim Android Device
How to Disable Recyclerview Items from Clicking
How to Delete Shared Preferences Data from App in Android