hi I have to make a view like the below image .
But when i make the parent view transperent , default background is showing like this:
a transperent view is showing behind the main view.
my xml starts like :
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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="wrap_content"
android:layout_margin="#dimen/_8sdp"
android:background="#color/red"
android:clipChildren="false"
android:clipToPadding="false">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/cl2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/_50sdp"
android:background="#drawable/rounded_corner_shadow"
android:clipChildren="false"
android:clipToPadding="false"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<FrameLayout
android:id="#+id/progressLayout_frame"
android:layout_width="#dimen/_90sdp"
android:layout_height="#dimen/_90sdp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:clickable="true"
android:visibility="visible"
app:layout_constraintBottom_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<View
android:id="#+id/bgCircle"
android:layout_width="#dimen/_70sdp"
android:layout_height="#dimen/_70sdp"
android:layout_gravity="center"
android:alpha="0.7"
android:background="#color/white"
android:visibility="visible" />
<RelativeLayout
android:id="#+id/progressLayout"
android:layout_width="#dimen/_80sdp"
android:layout_height="#dimen/_80sdp"
android:layout_gravity="center"
android:background="#android:color/transparent"
android:clickable="true"
>
<ProgressBar
android:id="#+id/progressbar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="#dimen/_80sdp"
android:layout_height="#dimen/_80sdp"
android:layout_centerHorizontal="true"
android:background="#drawable/circle_shape"
android:progressDrawable="#drawable/circular_progress_bar" />
<TextView
android:id="#+id/tvTimeCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginTop="60dp"
android:text="00:00"
android:textColor="#FFFFFF"
android:textSize="29sp"
app:customTypeFace="roboto_light" />
how can I hide the view behind . why does this layout come ? any suggestions would be helpful . thanks in advance
To remove default background of the dialog...
Step 1:
Create a custom_dialog.xml
<androidx.constraintlayout.widget.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="wrap_content"
android:layout_marginHorizontal="#dimen/_20sdp"
android:paddingHorizontal="#dimen/_25sdp"
android:paddingVertical="#dimen/_25sdp" >
<androidx.constraintlayout.widget.Guideline
android:id="#+id/left_vertical_gl"
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.02" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/right_vertical_gl"
android:layout_width="match_parent"
android:layout_height="1dp"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.98" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/center_horizontal_gl"
android:layout_width="match_parent"
android:layout_height="1dp"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.48" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/top_horizontal_gl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.044" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/end_horizontal_gl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.90" />
<TextView
android:id="#+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/segui_black"
android:text="Are You Sure?"
android:textColor="#484A67"
android:textSize="#dimen/_24ssp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/top_horizontal_gl" />
<TextView
android:id="#+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/_2sdp"
android:layout_marginBottom="12dp"
android:fontFamily="#font/segoe"
android:gravity="center"
android:text="Are you sure you want to sign out?"
android:textColor="#484A67"
android:textSize="#dimen/_11ssp"
app:layout_constraintEnd_toStartOf="#+id/right_vertical_gl"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView9" />
<TextView
android:id="#+id/yesTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/_20sdp"
android:fontFamily="#font/segui_semi_bold"
android:padding="#dimen/_5sdp"
android:text="Yes"
android:textColor="#AD7BFF"
app:layout_constraintEnd_toStartOf="#+id/right_vertical_gl"
app:layout_constraintTop_toBottomOf="#+id/textView10" />
<TextView
android:id="#+id/noTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="#dimen/_30sdp"
android:fontFamily="#font/segoe"
android:padding="#dimen/_5sdp"
android:text="No"
android:textColor="#6D6E85"
app:layout_constraintBottom_toBottomOf="#+id/yesTv"
app:layout_constraintEnd_toStartOf="#+id/yesTv"
app:layout_constraintTop_toTopOf="#+id/yesTv"
tools:layout_editor_absoluteX="143dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
Step 2:
Go to your dialog activity
Add the below line to your dialog code
popUpDialog.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
Complete code of the dialog
private lateinit var popUpDialog: Dialog
private fun buyLifeLineDialog() {
popUpDialog.setContentView(R.layout.dialog_buy_lifelines)
popUpDialog.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
val yesTv = popUpDialog.findViewById<TextView>(R.id.yesTv);
val noTv = popUpDialog.findViewById<TextView>(R.id.noTv);
popUpDialog.show()
yesTv.setOnClickListener {
if (isCheatLl) {
mViewModel.buyCheatLifeline(index,lifeLinesPackagesModel)
}
else{
mViewModel.buyRespawnLifeline(index,lifeLinesPackagesModel)
}
popUpDialog.dismiss()
}
noTv.setOnClickListener {
popUpDialog.dismiss()
}
}
I don't know how do you display this window in your app , but I suppose that you display it as custom dialog , so the problem is that you need to add a transparent theme for your dialog to get the same design or your dialog will fill the transparent spaces with this black color or white depends on your app theme , so to solve this problem you need to add this style in your theme.xml file or style.xml
<style name="AlertDialogCustom" parent="#android:style/Theme.Dialog">
<item name="android:windowBackground">#android:color/transparent</item>
</style>
and then you create a new custom dialog in your activity like this
//Here i will create new dialog with a custom style which I added in Theme.xml
final AlertDialog dialog2 = new AlertDialog.Builder(MainActivity.this,R.style.AlertDialogCustom).create();
LayoutInflater inflater = getLayoutInflater();
//Here I added my xml file , you can replace test with your own xml file
View convertView = (View) inflater.inflate(R.layout.test, null);
dialog2.setView(convertView);
dialog2.setCancelable(false);
//Here we tell the dialog to display , you can call show() when click a button
dialog2.show();
and here it's my simple design to get a transparent background
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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="350dp"
android:layout_margin="8dp"
android:background="#android:color/transparent"
android:clipChildren="false"
android:clipToPadding="false">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/cl2"
android:layout_width="350dp"
android:layout_height="350dp"
android:layout_marginTop="50dp"
android:background="#FFFFFF"
android:clipChildren="false"
android:clipToPadding="false"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<FrameLayout
android:id="#+id/progressLayout_frame"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:clickable="true"
android:visibility="visible"
app:layout_constraintBottom_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<View
android:id="#+id/bgCircle"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_gravity="center"
android:background="#drawable/pers_icon"
android:visibility="visible" />
<RelativeLayout
android:id="#+id/progressLayout"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_gravity="center"
android:background="#android:color/transparent"
android:clickable="true">
</RelativeLayout>
</FrameLayout>
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
tools:layout_editor_absoluteX="218dp"
tools:layout_editor_absoluteY="129dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Now this is the final result , you can make your own design
Related
I would make an insert FAB in my CardView like the one set by default in the BottomAppBar.
I changed my CardView to MaterialCardView to change the bottom edge bu setting the BottomAppBarTopEdgeTreatment
The issue is that i'm playing with the fabMargin, roundedCornerRadius, cradleVerticalOffset and fabDiameter but i can't set it's values to get the result from the native BottomAppBar inset FAB.
so which values should i set in it?
Desired behaviour would be like this (Actual picture of my BottomAppBar):
While i get this (Actual picture of my CardView):
My FAB code looks like this:
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/btnScan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:contentDescription="#string/nuovo_documento"
android:translationY="-36dp"
app:layout_anchor="#id/cardView"
app:layout_anchorGravity="bottom|center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/cardView"
app:srcCompat="#drawable/ic_outline_qr_code_scanner"
app:tint="#color/white" />
And the code where i set the shape to the Card is the following:
val bottomAppBarTreatment = BottomAppBarTopEdgeTreatment(16f, 2f, 8f)
bottomAppBarTreatment.fabDiameter = 110f
cardView.shapeAppearanceModel = cardView.shapeAppearanceModel.toBuilder()
.setBottomEdge(bottomAppBarTreatment)
.build()
You can use something like:
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/btnScan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:translationY="24dp"
../>
and:
val bottomAppBarTopEdgeTreatment = BottomAppBarTopEdgeTreatment(
resources.getDimension(R.dimen.margin), //5dp
resources.getDimension(R.dimen.rounded_corner), //8dp
resources.getDimension(R.dimen.vertical_offset) //0dp
)
bottomAppBarTopEdgeTreatment.fabDiameter = resources.getDimension(R.dimen.diameter) //56dp
cardView.shapeAppearanceModel = cardView.shapeAppearanceModel.toBuilder()
.setTopEdge(bottomAppBarTreatment)
.build()
I'm using below code snippet to achive this result using background image like below.
XML File:
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout 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:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
tools:openDrawer="start">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/transparent">
<RelativeLayout
android:id="#+id/rr_fab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/ll_bottom_nav"
android:layout_below="#+id/ll_top"
android:background="#android:color/transparent">
<LinearLayout
android:id="#+id/ll_last"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#android:color/transparent"
android:foreground="#android:color/transparent"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#android:color/transparent"
android:foreground="#android:color/transparent">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/fac_home"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="#dimen/padding_10"
app:backgroundTint="#color/colorPrimary"
app:srcCompat="#mipmap/home" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:id="#+id/ll_bottom_nav"
android:layout_width="match_parent"
android:layout_height="#dimen/padding_50"
android:layout_alignParentBottom="true"
android:layout_centerVertical="true"
android:layout_marginTop="-25dp"
android:background="#drawable/cut_nav_full_another_grey_two"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="10"
app:layout_behavior="com.wpa3.productshopify.widget.BottomNavigationViewBehavior">
<TextView
android:id="#+id/tv_category"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2.2"
android:drawableTop="#mipmap/category"
android:gravity="center"
android:text="#string/category"
android:textColor="#color/gray71"
android:textSize="#dimen/text_size_16" />
<TextView
android:id="#+id/tv_orders"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2.5"
android:drawableTop="#mipmap/order"
android:gravity="center"
android:text="#string/track_your_order"
android:textColor="#color/gray71"
android:textSize="#dimen/text_size_16" />
<View
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#android:color/transparent" />
<TextView
android:id="#+id/tv_profile"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2.5"
android:drawableTop="#mipmap/profile"
android:gravity="center"
android:text="#string/my_account"
android:textColor="#color/gray71"
android:textSize="#dimen/text_size_16" />
<TextView
android:id="#+id/tv_more"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.8"
android:drawableTop="#mipmap/more"
android:gravity="center"
android:text="#string/more"
android:textColor="#color/gray71"
android:textSize="#dimen/text_size_16" />
</LinearLayout>
</RelativeLayout>
</androidx.drawerlayout.widget.DrawerLayout>
Background Image = https://imgur.com/a/3cOhy9E
Hope this may helps you.
I have a layout for my recyclerview item:
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView 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="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="8dp"
android:orientation="vertical">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:orientation="vertical">
<ImageView
android:id="#+id/iv_hotel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_launcher_background" />
<TextView
android:id="#+id/tv_hotel_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/iv_hotel"
tools:text="Belleclaire Hotel" />
<include
android:id="#+id/include"
layout="#layout/include_stars_set"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="#+id/tv_hotel_name"
app:layout_constraintTop_toBottomOf="#+id/tv_hotel_name" />
<TextView
android:id="#+id/tv_hotel_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="#+id/include"
app:layout_constraintTop_toBottomOf="#+id/include"
tools:text="250 West 77th Street, Manhattan" />
<TextView
android:id="#+id/tv_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="#+id/tv_hotel_address"
app:layout_constraintTop_toBottomOf="#+id/tv_hotel_address"
tools:text="100.0" />
<TextView
android:id="#+id/tv_suites_available_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/label_suites_availability"
app:layout_constraintStart_toStartOf="#+id/tv_distance"
app:layout_constraintTop_toBottomOf="#+id/tv_distance" />
<TextView
android:id="#+id/tv_suites_available"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintStart_toEndOf="#+id/tv_suites_available_label"
app:layout_constraintTop_toTopOf="#+id/tv_suites_available_label" />
<ProgressBar
android:id="#+id/progress_hotel_image"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="#+id/iv_hotel"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/iv_hotel" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
It seems like this:
enter image description here
However after building I have this view:
enter image description here
As you can see, I see only a half of my progressbar after I'm trying to dowload an image to my iv_hotel with a help of Glide.
How can I solve this problem? I'm a bit bad at xml guidelines understanding, so I'm asking for a help(
Use placeholder to show default image while a request is in progress
Glide.with(context)
.load(url)
.placeholder(R.drawable.placeholder)
.into(view);
if (!imageUrl.isNullOrEmpty()) {
imageView?.let { iv ->
Glide.with(iv.context)
.load(AppUtility.IMAGE_THUMB_URL.plus(imageUrl))
.apply(options)
.into(iv)
}
} else {
imageView?.setImageDrawable(error)
// set here your error img
}
private void setupOnbaordingItems()
{
List<OnboardingItem> onboardingItems=new ArrayList<>();
OnboardingItem itemsPayOnline=new OnboardingItem();
itemsPayOnline.setTitle("Pay Your Bill Online");
itemsPayOnline.setDescription("Electric bill payment is a feature of online , mobile and telephone and banking ");
itemsPayOnline.setImage(R.drawable.pay_online);
OnboardingItem itemsOnTheWay=new OnboardingItem();
itemsPayOnline.setTitle("Your Food Is On The Way");
itemsPayOnline.setDescription("Our delievery rider is on the way to deliver your order ");
itemsPayOnline.setImage(R.drawable.on_thw_way);
OnboardingItem itemEatTogather=new OnboardingItem();
itemsPayOnline.setTitle("Eat Togather");
itemsPayOnline.setDescription("Enjoy your meal and have a great day,Dont forgot oto rate us ");
itemsPayOnline.setImage(R.drawable.eat_togather);
onboardingItems.add(itemsPayOnline);
onboardingItems.add(itemsOnTheWay);
onboardingItems.add(itemEatTogather);
onboardingAdapter=new OnboardingAdapter(onboardingItems);
}
Adapter shows only one item where i want to add 3 onboard stories to
adapter
Help me to solve the issue
activity_onboarding.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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"
android:background="#color/colorBackground"
tools:context=".OnboardingActivity">
<com.google.android.material.button.MaterialButton
android:id="#+id/buttonOnboardingAction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:layout_marginBottom="15dp"
android:layout_marginEnd="20dp"
android:textSize="15sp"
app:cornerRadius="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<androidx.viewpager2.widget.ViewPager2
android:id="#+id/onboardingViewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:id="#+id/layoutOnboardingIndicators"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:orientation="horizontal"
android:padding="16dp"
app:layout_constraintBottom_toBottomOf="#+id/buttonOnboardingAction"
app:layout_constraintEnd_toStartOf="#id/buttonOnboardingAction"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#id/buttonOnboardingAction"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
The item container for the activity xml file
I am not able to find the error if anybody can help me find it would
be great help to me
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="30dp"
android:layout_marginLeft="30dp"
android:layout_marginEnd="30dp"
android:layout_marginBottom="50dp"
android:gravity="center"
android:orientation="vertical"
android:padding="20dp">
<ImageView
android:id="#+id/imageOnboarding"
android:layout_width="260dp"
android:layout_height="260dp"
android:layout_margin="15dp"
android:adjustViewBounds="true"
android:contentDescription="#string/app_name"/>
<TextView
android:id="#+id/textTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="#color/colorTextPrimary"
android:textSize="20sp"
android:textStyle="bold"/>
<TextView
android:id="#+id/textDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="#color/colorTextSecondary"
android:textSize="18sp"/>
</LinearLayout>
I have three onboarding items in my function where adapter at a
time shows only one item.
I tried windowSoftInputMode in manifest nothing worked the views get pushed up when the keyboard is opened I tried different approaches but none of them worked. The recycler view collapses with the edit text but it is below the guide line separator.
Image when keyboard is opened:
Image when the keyboard is not opened:
<androidx.constraintlayout.widget.ConstraintLayout 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:background="#color/bg_color_for_screen">
<!--Guide line left-->
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guide_line_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_begin="#dimen/padding_margin_15" />
<!--Guide line right-->
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guide_line_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_end="#dimen/padding_margin_15" />
<!--Guide line for separating image-->
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guide_line_separator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.17" />
<!--Image for the top header-->
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="match_parent"
android:layout_height="0dp"
android:scaleType="centerCrop"
app:layout_constraintBottom_toTopOf="#+id/guide_line_separator"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#mipmap/splash_bg" />
<!--back button image-->
<ImageView
android:id="#+id/step_back_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/padding_margin_15"
android:scaleType="centerCrop"
android:src="#mipmap/ic_back_arrow"
android:tint="#color/white"
android:visibility="visible"
app:layout_constraintStart_toStartOf="#id/guide_line_left"
app:layout_constraintTop_toTopOf="parent" />
<!--title for the screen-->
<androidx.appcompat.widget.AppCompatTextView
android:id="#+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/padding_margin_10"
android:layout_marginLeft="#dimen/padding_margin_5"
android:layout_marginTop="#dimen/padding_margin_18"
android:fontFamily="#font/nunito_medium"
android:text="#string/blank"
android:textColor="#color/white"
android:textSize="#dimen/text_size_18"
app:layout_constraintStart_toEndOf="#+id/step_back_button"
app:layout_constraintTop_toTopOf="parent" />
<!--edit text for searching by the keyword-->
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/edit_text_search"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/padding_margin_10"
android:layout_marginTop="#dimen/padding_margin_12"
android:background="#drawable/edit_text_background"
android:drawableStart="#mipmap/ic_search"
android:drawablePadding="#dimen/padding_margin_8"
android:fontFamily="#font/nunito_regular"
android:hint="#string/blank"
android:padding="#dimen/padding_margin_10"
android:textSize="#dimen/text_size_15"
app:layout_constraintEnd_toStartOf="#+id/guide_line_right"
app:layout_constraintStart_toStartOf="#id/guide_line_left"
app:layout_constraintTop_toBottomOf="#+id/label" />
<!--recycler view for the list -->
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="#dimen/padding_margin_5"
android:layout_marginBottom="#dimen/padding_margin_5"
android:background="#color/transparent"
android:visibility="visible"
app:layout_constraintBottom_toTopOf="parent"
app:layout_constraintEnd_toEndOf="#id/guide_line_right"
app:layout_constraintStart_toStartOf="#id/guide_line_left"
app:layout_constraintTop_toBottomOf="#+id/guide_line_separator" />
</androidx.constraintlayout.widget.ConstraintLayout>
Please try to remove this line from rv and then try it.
app:layout_constraintBottom_toTopOf="parent"
Current Implementation:
Requirement:
Below is the custom _tab xml which I am inflating into Tablayout and also I need the indicator to take the width of custom square box.I have added the custom_tab.xml layout file.please let me know how to implement one like requirement.
Added tab.xml too
Custom_tab.xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
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:layout_gravity="center"
android:layout_margin="10dp"
app:cardCornerRadius="8dp">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="#drawable/round_corners_rectangle"
android:gravity="center_vertical"
android:orientation="vertical">
<ImageView
android:id="#+id/imageView_tabs"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_gravity="center"
android:layout_marginTop="-15dp"
android:contentDescription="#string/app_name"
android:src="#drawable/agent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/textView_tabs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="10dp"
android:text="rooms"
android:textColor="#color/white"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/imageView_tabs" />
<View
android:id="#+id/underLine"
android:layout_width="match_parent"
android:layout_height="10dp"
android:layout_marginBottom="5dp"
android:background="#drawable/chat_indicator_line"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#id/textView_tabs" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
Tab.xml:
<LinearLayout
android:id="#+id/linear_tab"
android:layout_width="match_parent"
android:layout_height="90dp"
android:alpha="0.6">
<android.support.design.widget.TabLayout
android:id="#+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="#color/black"
android:baselineAligned="false"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp"
app:tabIndicatorColor="#color/white"
app:tabIndicatorHeight="3dp"
app:tabPaddingEnd="7dp"
app:tabPaddingStart="3dp" />
</LinearLayout>
Below is the code How I am adding customview programmatically:
private void createTabs() {
for (int i = 0; i < tabArray.length; i++) {
View viewCustomTab =
LayoutInflater.from(this).inflate(R.layout.custom_tab, null);//get custom view
viewCustomTab.setBackgroundColor(getResources().getColor(R.color.black));
ImageView imageViewTab = viewCustomTab.findViewById(R.id.imageView_tabs);
imageViewTab.setImageResource(tabIcons[i]);
TextView textViewTab =
viewCustomTab.findViewById(R.id.textView_tabs);
textViewTab.setText(tabArray[i]);
TabLayout.Tab tab = mTabLayout.getTabAt(i);//get tab via position
if (tab != null) {
tab.setCustomView(viewCustomTab);//set custom view
}
}
}