Button Not Showing Up In Layout
Your TextView
is taking up all of the space do to the height and width being match_parent
. And since LinearLayouts
are laid out in sequential order there's no space for anything that comes after it.
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Hello World!"
android:gravity="center"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Change that to wrap_content
, use layout_weight
, or a specific dimension (whatever suits your needs).
Button not displaying in LinearLayout
Try this.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="fill_parent" android:layout_height="45dip"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView android:layout_width="wrap_content"
android:layout_height="45dip" android:paddingLeft="5dip"
android:paddingRight="5dip" android:textStyle="bold" android:textSize="17dip"
android:gravity="center_vertical" android:id="@+id/tvChild"
android:text="Children" android:textColor="#ffCCCC22"
/>
<Button android:id="@+id/submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Submit" />
</LinearLayout>
Use android:layout_width="wrap_content"
instead of android:layout_width="fill_parent"
for TextView
and Button
Android: Activity content (Button) not showing
You're never calling setContentView
to tell it to use your layout:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
So you're getting a blank activity with no content.
Button is not showing on View
You are using RelativeLayout
as parent and adding constraints
to Button
which only works when the parent is ConstraintLayout
, to achieve same in RelativeLayout
try android:layout_alignParentStart="true"
and android:layout_below="@+id/toolbar"
as in
<Button
android:id="@+id/tv_welcome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:backgroundTint="@color/black"
android:elevation="6dp"
android:text="Hello,"
android:textColor="#fff"
android:textSize="35sp"
android:layout_alignParentStart="true"
android:layout_below="@+id/toolbar" />
Also remove elevation on View
as it is just setting background
<View
android:id="@+id/view"
android:layout_width="match_parent"
android:layout_height="250dp"
android:background="@drawable/dashboard_layout"
android:transitionName="bg_anim"
android:layout_alignParentTop="true"/>
Button not display below RecycleView in Android Studio
1. Add a RelativeLayout
below AppBarLayout
and put Button
and RecyclerView
inside RelativeLayout
.
2. Add attribute android:layout_alignParentBottom="true"
to Button
to align it at the bottom
of screen.
3. Add attribute android:layout_above="@id/button7"
to RecyclerView
to show it above Button
.
Update your layout as below:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:theme="@style/AppTheme.AppBarLayout">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/button7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Save"
android:textColor="@android:color/black" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/button7"/>
</RelativeLayout>
</LinearLayout>
OUTPUT:
Related Topics
Android: How to Open a Specific Folder Via Intent and Show Its Content in a File Browser
Android Set Height and Width of Custom View Programmatically
Android Studio - Failed to Apply Plugin [Id 'Com.Android.Application']
How to Make My App Work in All Devices
Android - How to Make a Button Click Play a Sound File Every Time It Been Pressed
Missing Android Platform(S) Detected
How to Restrict Entry of Numbers But Allow All the Special Characters and Alphabets in Edittext
Failure Install Parse Failed Manifest Malformed
Disable Ssl as a Protocol in Httpsurlconnection
Chrome on Android Resizes Font
How to Set Up Android Studio to Work Completely Offline
Android Blur View (Blur Background Behind the View)
Install Apps Silently, With Granted Install_Packages Permission
How to Fix White Screen on App Start Up
Android.Support.V7.App.Activitycompat Not Found
How to Change Background Color of Layout of List-View Item Using Array-Adapter