I want to add applications to the ad. But I fail I want to add about the position advertised. Codes are as follows:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="info.androidhive.materialtabs.fragments.OneFragment">
<TextView
android:id="#+id/tarih"
android:textColor="#04B038"
android:textSize="15dp"
android:textStyle="bold"
android:layout_marginTop="5dp"
android:layout_gravity="center_horizontal"
android:text=""
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ListView
android:id="#+id/olaylar_liste"
android:layout_width="match_parent"
android:layout_height="wrap_content"></ListView>
<ProgressBar
android:layout_gravity="center_vertical|center_horizontal"
android:id="#+id/progress_olaylar"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</FrameLayout>
<LinearLayout
android:layout_gravity="bottom"
android:orientation="horizontal"
android:id="#+id/adLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"></LinearLayout>
</LinearLayout>
I want adview showing bottom on linearlayout. Adview # + id /adLayout will be displayed on the Layout
Please help me.
try this
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="info.androidhive.materialtabs.fragments.OneFragment">
<TextView
android:id="#+id/tarih"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:text="Header"
android:textColor="#04B038"
android:textSize="15dp"
android:textStyle="bold" />
<LinearLayout
android:id="#+id/adLayout"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:background="#ff0000"
android:orientation="horizontal"></LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/adLayout"
android:layout_below="#+id/tarih">
<ListView
android:id="#+id/olaylar_liste"
android:layout_width="match_parent"
android:layout_height="wrap_content"></ListView>
<ProgressBar
android:id="#+id/progress_olaylar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal" />
</FrameLayout>
</RelativeLayout>
Related
I have bellow layout:
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.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=".activities.completion_information_activity.CompletionInformationActivity">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/appBarCompletionInformation"
android:layout_width="match_parent"
android:layout_height="240dp"
android:theme="#style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="#+id/toolbarLayoutCompletionInformation"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minHeight="60dp"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:toolbarId="#+id/toolbarCompletionInformation">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbarCompletionInformation"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:contentInsetStart="0dp"
android:contentInsetLeft="0dp"
android:contentInsetEnd="0dp"
android:contentInsetRight="0dp"
app:contentInsetEnd="0dp"
app:contentInsetLeft="0dp"
app:contentInsetRight="0dp"
app:contentInsetStart="0dp"
app:layout_collapseMode="pin"
app:popupTheme="#style/AppTheme.PopupOverlay"
app:title="SSADSDWQEWQ">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center">
<ImageButton
android:id="#+id/imgBackCompletionInformation"
android:layout_width="50dp"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:background="#null"
android:src="#drawable/ic_baseline_arrow_back_24"
app:tint="#color/black" />
</RelativeLayout>
</androidx.appcompat.widget.Toolbar>
<RelativeLayout
android:id="#+id/relativeLayoutCompletionInformation"
android:layout_width="75dp"
android:layout_height="75dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="25dp"
android:background="#drawable/border">
<ImageView
android:id="#+id/imgProfileCompletionInformation"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_centerInParent="true"
android:adjustViewBounds="true"
android:padding="3dp"
android:scaleType="fitXY" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/imgProfileCompletionInformation"
android:layout_alignParentRight="true"
android:src="#drawable/ic_baseline_photo_camera_24" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeLayoutToFadeOutCompletionInformation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:layout_collapseMode="parallax">
<TextView
android:id="#+id/txtProfileNameCompletionInformation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="User Name"
android:textColor="#color/black"
android:textSize="20sp"
android:textStyle="bold" />
</RelativeLayout>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/bright_gray"
android:fitsSystemWindows="true"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="...CompletionInformationActivity"
tools:showIn="#layout/activity_completion_information">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/one"
android:layout_width="match_parent"
android:layout_height="70dp"
android:background="#drawable/custom_cardview_bottom_top_shadow"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/edtUserNameEdit"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_alignParentLeft="true"
android:background="#drawable/text_input_layout_stroke_color"
android:hint="User Name"
android:inputType="text"
android:isScrollContainer="true"
android:maxLines="1"
android:padding="5dp"
android:scrollHorizontally="true" />
<TextView
android:id="#+id/txtNameEditCompletion"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignRight="#+id/edtUserNameEdit"
android:layout_alignParentRight="true"
android:gravity="center_vertical"
android:text="User Name"
android:textColor="#color/black"
android:textStyle="bold" />
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Problem:
When extend AppCompatEditText it overlap on TextView.
I need that AppCompatEditText be android:layout_width="wrap_content". And when user type extend AppCompatEditText to left TextView.
Replace your xml to this one :
I have made some changes as your requirements :
I have changed your RelativeLayout to the LinearLayout and made orientation horizontal with 1 weight of AppCompactTextView
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.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">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/appBarCompletionInformation"
android:layout_width="match_parent"
android:layout_height="240dp"
android:theme="#style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="#+id/toolbarLayoutCompletionInformation"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minHeight="60dp"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:toolbarId="#+id/toolbarCompletionInformation">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbarCompletionInformation"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:contentInsetStart="0dp"
android:contentInsetLeft="0dp"
android:contentInsetEnd="0dp"
android:contentInsetRight="0dp"
app:contentInsetEnd="0dp"
app:contentInsetLeft="0dp"
app:contentInsetRight="0dp"
app:contentInsetStart="0dp"
app:layout_collapseMode="pin"
app:popupTheme="#style/AppTheme.PopupOverlay"
app:title="SSADSDWQEWQ">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center">
<ImageButton
android:id="#+id/imgBackCompletionInformation"
android:layout_width="50dp"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:background="#null"
android:src="#drawable/ic_baseline_arrow_back_24"
app:tint="#color/black" />
</RelativeLayout>
</androidx.appcompat.widget.Toolbar>
<RelativeLayout
android:id="#+id/relativeLayoutCompletionInformation"
android:layout_width="75dp"
android:layout_height="75dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="25dp"
android:background="#drawable/border">
<ImageView
android:id="#+id/imgProfileCompletionInformation"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_centerInParent="true"
android:adjustViewBounds="true"
android:padding="3dp"
android:scaleType="fitXY" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/imgProfileCompletionInformation"
android:layout_alignParentRight="true"
android:src="#drawable/ic_baseline_photo_camera_24" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeLayoutToFadeOutCompletionInformation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:layout_collapseMode="parallax">
<TextView
android:id="#+id/txtProfileNameCompletionInformation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="User Name"
android:textColor="#color/black"
android:textSize="20sp"
android:textStyle="bold" />
</RelativeLayout>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/bright_gray"
android:fitsSystemWindows="true"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="...CompletionInformationActivity"
tools:showIn="#layout/activity_completion_information">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/one"
android:layout_width="match_parent"
android:layout_height="70dp"
android:background="#drawable/custom_cardview_bottom_top_shadow"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:ignore="MissingConstraints">
<RelativeLayout
android:layout_toStartOf="#+id/txtNameEditCompletion"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/edtUserNameEdit"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_alignParentStart="true"
android:background="#drawable/text_input_layout_stroke_color"
android:hint="User Name"
android:inputType="text"
android:isScrollContainer="true"
android:maxLines="1"
android:padding="5dp"
android:scrollHorizontally="true" />
</RelativeLayout>
<TextView
android:layout_alignParentEnd="true"
android:id="#+id/txtNameEditCompletion"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:gravity="center_vertical"
android:text="User Name"
android:textColor="#color/black"
android:textStyle="bold" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout_editor_absoluteY="25dp">
<TableLayout
android:id="#+id/tableLayoutHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textViewDeviceName">
</TableLayout>
<ScrollView
android:id="#+id/scrollViewLayoutFoo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:minWidth="150dp"
android:minHeight="60dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tableLayoutHeader">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/red"
android:orientation="vertical">
<LinearLayout
android:id="#+id/linearLayoutFragments1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" />
<LinearLayout
android:id="#+id/linearLayoutFragments2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"></LinearLayout>
</LinearLayout>
</ScrollView>
</android.support.constraint.ConstraintLayout>
linearLayoutFragments1 and linearLayoutFragments2 have many fragments added at runtime. Unfortunately, scrollViewLayoutFoo is not constrained below tableLayoutHeader, but overflows into tableLayoutHeader.
Could anyone offer a tip on how to fix this?
You were missing some constraints.
You need to constraint the TabLayout to the parent from start/top/end and scroll view constraint to the bottom of it.
There are also referenced some views that are not in the example so you might have to update them accordingly.
<android.support.constraint.ConstraintLayout 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">
<TableLayout
android:id="#+id/tableLayoutHeader"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:layout_height="48dp" />
<ScrollView
android:id="#+id/scrollViewLayoutFoo"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:minHeight="60dp"
android:minWidth="150dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tableLayoutHeader">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FF0000"
android:orientation="vertical">
<LinearLayout
android:id="#+id/linearLayoutFragments1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
<LinearLayout
android:id="#+id/linearLayoutFragments2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
</LinearLayout>
</ScrollView>
</android.support.constraint.ConstraintLayout>
I have this code where I always get an error about a mismatched tag, I cant see the error myself, can someone help me? thanks a million.
And I also get this error: Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
<?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"
tools:context=".DetailsSongs">
<android.support.design.widget.AppBarLayout
android:layout_widht="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="FFECB3"
android:padding="16dp"
android:text="#string/songdetailsdescription" />
</android.support.design.widget.AppBarLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientaion="vertical"
android:weightSum="1"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<Linearlayout
android:layout_width="match_parent"
android:layouth_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layouth_height="match_content"
android:layout_marginBottom="16dp"
android:layout_marginTop="16dp"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#drawable/image_placeholder_dark_large"
android:contentDescription="#string/songdetailscontentdescriptionalbumart"
android:scaleType="center" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:paddingTop="16dp"
android:text="#string/songnameplaceholder"
android:textSize="24sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:paddingTop="4dp"
android:text="#string/songauthorplaceholder"
android:textSize="16sp"
android:textStyle="bold" />
<Button
style="?android:attr/buttonBarButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableEnd="#drawable/media_controls_play_dark_small"
android:gravity="center"
android:paddingBottom="2dp"
android:paddingBtottom="2dp"
android:text="#string/songdetailsplaynow" />
This is where is says that there is an error (LinearLayout) below this comment
</Linearlayout>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/songdetailssimilarsongs"
android:textSize="18sp" />
<HorizontalScrollView
android:id="#+id/related_albums"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp" >
<include layout="#layout/relatedsongslist" />
</HorizontalScrollView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="16dp"
android:text="#string/songdescriptionplaceholder" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="1">
<include layout="#layout/player" />
</LinearLayout>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
almost all your tags are mismatched and its causing the problem, i dont know what you trying but i think your best bet will be to try and restart the design again
but this is what i could help. rewrote your xml.
<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"
tools:context=".DetailsSongs">
<android.support.design.widget.AppBarLayout
android:layout_widht="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="FFECB3"
android:padding="16dp"
android:text="#string/songdetailsdescription" />
</android.support.design.widget.AppBarLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientaion="vertical"
android:weightSum="1"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<Linearlayout
android:layout_width="match_parent"
android:layouth_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layouth_height="match_content"
android:layout_marginBottom="16dp"
android:layout_marginTop="16dp"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#drawable/image_placeholder_dark_large"
android:contentDescription="#string/songdetailscontentdescriptionalbumart"
android:scaleType="center" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:paddingTop="16dp"
android:text="#string/songnameplaceholder"
android:textSize="24sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:paddingTop="4dp"
android:text="#string/songauthorplaceholder"
android:textSize="16sp"
android:textStyle="bold" />
<Button
style="?android:attr/buttonBarButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableEnd="#drawable/media_controls_play_dark_small"
android:gravity="center"
android:paddingBottom="2dp"
android:paddingBtottom="2dp"
android:text="#string/songdetailsplaynow" />
</LinearLayout>
</Linearlayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/songdetailssimilarsongs"
android:textSize="18sp" />
<HorizontalScrollView
android:id="#+id/related_albums"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp" >
<include layout="#layout/relatedsongslist" />
</HorizontalScrollView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="16dp"
android:text="#string/songdescriptionplaceholder" />
</ScrollView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="1">
<include layout="#layout/player" />
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
Try this out and hopefully could help you
I am having LinearLayout inside scroll view. I want to set LinearLayout's top margin to 50dp programmatically using below code
convertView = inflater.inflate(R.layout.apps_detail_item, parent, false);
LinearLayout childLayout = (LinearLayout) convertView.findViewById(R.id.childLayout);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT
);
params.setMargins(0, 50, 0, 0);
childLayout.setLayoutParams(params);
But when I'm trying to run this code, my app is getting crash. Here is the error logs:
AndroidRuntime: FATAL EXCEPTION: main
Process: com.don.offers, PID: 11452
java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to android.widget.FrameLayout$LayoutParams
at android.widget.FrameLayout.onMeasure(FrameLayout.java:437)
at android.support.v4.widget.NestedScrollView.onMeasure(NestedScrollView.java:482)
at android.view.View.measure(View.java:17555)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
at android.view.View.measure(View.java:17555)
at se.emilsjolander.flipview.FlipView.measureChild(FlipView.java:252)
at se.emilsjolander.flipview.FlipView.measureChildren(FlipView.java:245)
at se.emilsjolander.flipview.FlipView.onMeasure(FlipView.java:228)
at android.view.View.measure(View.java:17555)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:728)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:464)
at android.view.View.measure(View.java:17555)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:728)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:464)
at android.view.View.measure(View.java:17555)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139)
at android.view.View.measure(View.java:17555)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
at android.view.View.measure(View.java:17555)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
at android.view.View.measure(View.java:17555)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
at android.view.View.measure(View.java:17555)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2615)
at android.view.View.measure(View.java:17555)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2027)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1185)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1391)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1073)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5903)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:773)
at android.view.Choreographer.doCallbacks(Choreographer.java:586)
at android.view.Choreographer.doFrame(Choreographer.java:556)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:759)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5268)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:902)
Here is my xml file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/background_color"
android:orientation="vertical">
<ScrollView
android:id="#+id/scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/bottomBar"
android:scrollbars="none">
<LinearLayout
android:id="#+id/childLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="200dp">
<ImageView
android:id="#+id/banner_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:src="#drawable/default_image_300_200" />
<View
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#drawable/top_tint" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
android:background="#drawable/bottom_tint">
<!--<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/logo"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:src="#drawable/ic_launcher"
app:border_color="#FFF"
app:border_overlay="true"
app:border_width="2dp" />-->
<ImageView
android:id="#+id/logo"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:scaleType="fitCenter"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/headLine"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="15dp"
android:layout_toLeftOf="#+id/dislike_btn"
android:layout_toRightOf="#+id/logo"
android:ellipsize="end"
android:singleLine="true"
android:textAppearance="#android:style/TextAppearance"
android:textColor="#color/white" />
</RelativeLayout>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="#+id/ratingbar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:orientation="horizontal"
android:padding="10dp">
<LinearLayout
android:id="#+id/people_used_count_layout"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/verified_date_txt_layout"
android:layout_weight=".4"
android:gravity="center_vertical">
<RatingBar
android:id="#+id/ratingBar"
style="?android:attr/ratingBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:isIndicator="true"
android:numStars="5"
android:rating="3.5" />
</LinearLayout>
<LinearLayout
android:id="#+id/verified_date_txt_layout"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight=".6"
android:gravity="center_vertical|right">
<TextView
android:id="#+id/downloadAndEarn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:ellipsize="end"
android:singleLine="true"
android:text="#string/download_use_earn_text"
android:textAppearance="#android:style/TextAppearance"
android:textColor="#color/text_color_dark_gray"
android:textSize="#dimen/fourteen_sp_text_size" />
<TextView
android:id="#+id/downloadAndEarnValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:text="₹20"
android:textAppearance="#android:style/TextAppearance"
android:textColor="#color/green"
android:textSize="#dimen/twentifour_sp_text_size"
android:textStyle="bold"
android:visibility="gone"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/price_discount_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp">
<TextView
android:id="#+id/appName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textAppearance="#android:style/TextAppearance"
android:textColor="#color/text_color_dark_gray"
android:textSize="#dimen/sixteen_sp_text_size" />
<TextView
android:id="#+id/appDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:textAppearance="#android:style/TextAppearance"
android:textColor="#color/text_color_dark_gray"
android:textSize="#dimen/fourteen_sp_text_size" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="5dp"
android:background="#color/divider_color" />
<LinearLayout
android:id="#+id/user_goals_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:orientation="vertical">
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
<RelativeLayout
android:id="#+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_alignParentBottom="true"
android:background="#drawable/button_background">
<TextView
android:id="#+id/installNow"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="#string/install_now_text"
android:textAppearance="#android:style/TextAppearance"
android:textColor="#color/white"
android:textSize="#dimen/sixteen_sp_text_size" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/app_progress"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#33000000"
android:visibility="gone"
>
<!--<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/white"
android:text="#string/please_wait"
/>-->
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
/>
</RelativeLayout>
</RelativeLayout>
I solved it myself. Here is the code
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.setMargins(0, 50, 0, 0);
childLayout.setLayoutParams(params);
I have an Android fragment with a EditText. Since I would like to enter there something, I managed to display the keyboard as well, when opening this fragment.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="#+id/viewgroup_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="#+id/viewgroup_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<View
android:id="#+id/view_placeholder"
android:layout_width="match_parent"
android:layout_height="336dp"
android:clickable="false"
android:src="#drawable/img_placeholder_400"
android:layout_weight="0.64" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="#dimen/margin_bot"
android:paddingLeft="#dimen/margin_left"
android:paddingRight="#dimen/margin_right"
android:paddingTop="20dp"
android:background="#color/dark"
android:focusableInTouchMode="true"
android:weightSum="1">
<RelativeLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter name"
android:id="#+id/textView_fragment_title"
android:textColor="#color/white"
android:clickable="false" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="You can enter your name here.. "
android:id="#+id/textView_fragment_subtitle"
android:textColor="#color/blueTone" />
</LinearLayout>
<ImageButton
android:id="#+id/btn_close_fragment_fragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="center"
android:src="#drawable/ic_darkblue_20"
android:layout_gravity="right"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
<EditText
android:layout_width="match_parent"
android:layout_height="40dp"
android:id="#+id/editText_fragment_content"
android:background="#color/white"
android:inputType="text"
android:imeOptions="actionDone"
android:hint="Enter name here ..."
android:layout_marginTop="10dp">
<requestFocus/>
</EditText>
</LinearLayout>
</FrameLayout>
</LinearLayout>
</LinearLayout>
But my keyboard is in front of my fragment, and thus my fragment is not visible anymore.
I would like to have my keyboard on the bottom, and on top of my soft keybaord my fragment as in this example screenshot
How can I put my fragment on top of the Android soft keyboard?
Following solved my issue:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="#+id/viewgroup_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:focusableInTouchMode="true"
android:layout_alignParentBottom="true"
android:weightSum="1">
<MY_STUFF>
</LinearLayout>
</RelativeLayout>