I've checked all the other posts I can find on this and can't get the icons to even show in the Design preview but it is showing the navigation bar block in design view (with no text or icons).
I am using a nested linear layout and I have set the icons to appear as white against a darker background tint, but when I set up the action bar and tab icon type, i chose the HOLO_DARK theme so they should have been white anyway (I added the icon tint as white too, just to see if that made a difference).
Here is my xml code for the activity:
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".LoginActivity">
<TextView
android:layout_width="match_parent"
android:layout_height="180dp"
android:layout_marginBottom="25dp"
android:paddingVertical="60dp"
android:text="#string/logintext"
android:textAlignment="center"
android:textColor="#color/white"
android:textSize="40sp" />
<TextView
android:id="#+id/useremail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="30dp"
android:text="#string/user_email"
android:textSize="20sp" />
<EditText
android:id="#+id/loginemailentryid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="30dp"
android:layout_marginBottom="30dp"
android:autofillHints=""
android:hint="#string/common_signin_button_text"
android:inputType="textEmailAddress"
android:minHeight="48dp"
tools:ignore="TextContrastCheck" />
<TextView
android:id="#+id/passwordtext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="30dp"
android:text="#string/password"
android:textSize="20sp" />
<EditText
android:id="#+id/loginpasswordentryid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="30dp"
android:layout_marginBottom="30dp"
android:autofillHints=""
android:hint="#string/prompt_password"
android:inputType="textPassword"
android:minHeight="38dp"
tools:ignore="TextContrastCheck" />
<Button
android:id="#+id/loginbuttonid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="30dp"
android:layout_marginBottom="25dp"
android:text="#string/login"
android:textSize="20sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="185dp"
android:orientation="horizontal">
<TextView
android:id="#+id/registeroption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="50dp"
android:paddingHorizontal="40dp"
android:text="#string/register"
android:textAlignment="center"
android:textSize="15sp" />
<TextView
android:id="#+id/forgotpasswordoption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingHorizontal="40dp"
android:text="#string/forgot_password_option"
android:textAlignment="center"
android:textColor="#color/design_default_color_primary"
android:textSize="15sp" />
</LinearLayout>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:layout_width="match_parent"
android:layout_height="46dp"
android:background="?android:attr/windowBackground"
android:backgroundTint="#color/design_default_color_primary"
app:itemIconTint="#fff"
app:itemTextColor="#fff"
app:labelVisibilityMode="labeled"
app:menu="#menu/navigation_menu"
app:showAsAction="ifRoom" />
</LinearLayout>
Here is my navigation menu code:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="#+id/homenav"
android:title="#string/homeiconmenu"
android:enabled="true"
android:icon="#drawable/ic_home"
android:visible="true" />
<item
android:id="#+id/scoresnav"
android:title="#string/scoresiconmenu"
android:enabled="true"
android:icon="#drawable/ic_scores"
android:visible="true" />
<item
android:id="#+id/profilenav"
android:title="#string/profileiconmenu"
android:enabled="true"
android:icon="#drawable/ic_account"
android:visible="true" />
</menu>
Some of the posts I have already checked and tried:
Android BottomNavigationView not shows
Bottom Navigation Bar not showing icons or text
Why my Bottom Navigation View does not show any titles or icons?
BottomNavigationView not show icon
Related
Using a android phone (samsung), my app view is being overlapped by the system navigation bar. I'd like the view to be end at above the system navigation bar
screenshot of issue
`
<?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"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="#+id/tv_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:textColor="#color/gray"
android:textSize="14sp" />
<TextView
android:id="#+id/tv_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/tv_date"
android:layout_marginRight="20dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="25dp"
android:textColor="#color/black"
android:textSize="22sp"
android:textStyle="bold" />
<View
android:id="#+id/v2"
android:layout_width="100dp"
android:layout_height="4dp"
android:layout_below="#+id/tv_message"
android:layout_marginLeft="10dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="5dp"
android:background="#drawable/border_main" />
/>
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
`
Tried a bunch of different xml options, with the expectation of the view ending before the system navigation bar.
Figured it out had the code below in my activity.
window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
removed that and it worked fine.
I know it is a small thing but I don't know why it is not working.
when I am putting custom drawable image it is not working. I want to have a transparent background button with corners (stroke).
below is the image.
<RelativeLayout 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="#drawable/welcome"
tools:context=".MainActivity">
<ImageView
android:id="#+id/app_logo"
android:layout_width="300dp"
android:layout_height="100dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="60dp"
android:src="#drawable/applogo"/>
<TextView
android:id="#+id/app_slogan"
android:layout_width="220dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_marginEnd="80dp"
android:layout_marginTop="140dp"
android:text="Find, Discover, Choose and buy anything online"
android:textAlignment="center"
android:textSize="22sp"
android:textStyle="bold|italic"
android:textColor="#color/design_default_color_primary"
/>
<Button
android:id="#+id/main_login_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="10dp"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:background="#drawable/buttons"
android:padding="20dp"
android:textAllCaps="false"
android:textSize="18sp"
android:text="Already have a account ? Login"
android:textColor="#android:color/white"
/>
<Button
android:id="#+id/main_join_now_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_above="#id/main_login_btn"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:background="#drawable/input_design"
android:padding="20dp"
android:textAllCaps="false"
android:textSize="18sp"
android:text="Already have a account ? Login"
android:textColor="#android:color/white"
/>
</RelativeLayout>
// Drawable resource file.
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:color="#fff"
android:width="3dp"
/>
<corners
android:radius="15dp"
/>
login button should have a background of input_design.xml but I don't know why it is not working.
help me out
thank you in advance.
To achieve a transparent background on your button perhaps use Widget.MaterialComponents.Button.OutlinedButton.
You will need this line in your build.gradle (if not there already):
implementation 'com.google.android.material:material:1.2.1'
Your button would then simply look like this:
<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/teal_700"
tools:context=".FirstFragment">
<Button
android:id="#+id/button"
style="#style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="32dp"
android:text="I am a Button!"
android:textColor="#color/white"
app:cornerRadius="15dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:rippleColor="#color/white"
app:strokeColor="#color/white"
app:strokeWidth="3dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
Notice:
style="#style/Widget.MaterialComponents.Button.OutlinedButton"
android:textColor="#color/white"
app:cornerRadius="15dp"
app:rippleColor="#color/white"
app:strokeColor="#color/white"
app:strokeWidth="3dp"
and that will produce:
Simply, I have a linear layout that separates the screen to 2 pieces from middle and in the first piece I have a constraint layout that contains mountain.png .Because of i set NoActionBar and white for statusBarColor in Themes.xml, as a result above the image there is area that seems white.So I want to remove the white area and scale the image through status bar of the phone.
I tried to remove status bar, it didn't work.
I tried to add android:fitsSystemWindows="true" attribute to .XML file and it didn't work too.
My .xml file
<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"
tools:context=".ui.sign_in.telephone.PhoneNumberFragment"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="5"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:background="#drawable/mountain">
<TextView
android:id="#+id/baslaText"
android:layout_width="match_parent"
android:gravity="center"
android:layout_marginTop="100dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginLeft="100dp"
android:layout_marginRight="100dp"
android:layout_height="wrap_content"
android:textSize="38sp"
android:textColor="#color/white"
android:text="Başlayın" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginRight="50dp"
android:layout_marginLeft="50dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#id/baslaText"
android:layout_marginTop="20dp"
android:textColor="#color/white"
android:textSize="16sp"
android:text="Taşımaya başlamak için kaydolun, ilk \n olarak telefon numaranızı girin"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.cardview.widget.CardView
android:elevation="4dp"
app:cardCornerRadius="14dp"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/telephoneNumber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="30dp"
android:text="Telefon numaranızı giriniz"
android:textColor="#color/black"
android:textSize="28sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:layout_width="match_parent"
android:gravity="center"
android:id="#+id/telephoneText"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:textSize="18sp"
app:layout_constraintRight_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#id/telephoneNumber"
android:text="Taşımaya başlamak için kaydolun, ilk \n olarak telefon numaranızı girin"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/telephoneTag"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="40dp"
android:text="Telefon Numarası"
android:textColor="#color/black"
android:textSize="20sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="#id/telephoneText" />
<com.google.android.material.textfield.TextInputLayout
android:elevation="2dp"
app:cardCornerRadius="5dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/telephoneNumberInput"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#id/telephoneTag"
android:layout_marginTop="20dp"
app:errorEnabled="true"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
>
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/telephoneNumberEditText"
android:layout_width="match_parent"
android:background="#android:color/transparent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:inputType="number"
android:hint="+.. ... ... .. .."
android:maxLength="12"
android:textColor="#color/black"
android:textSize="14sp"
/>
</com.google.android.material.textfield.TextInputLayout>
<Button
android:id="#+id/button"
android:layout_width="match_parent"
android:layout_height="60dp"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginLeft="30dp"
android:layout_marginBottom="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="10dp"
android:background="#color/purple_500"
android:backgroundTint="#color/purple_500"
android:text="Başlayın"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#id/telephoneNumberInput" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
My themes.xml file.
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.UI" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">#color/teal_200</item>
<item name="colorPrimaryVariant">#color/white</item>
<item name="colorOnPrimary">#color/white</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>
</resources>
write this on your activity onCreate:
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
getWindow().setStatusBarColor(Color.TRANSPARENT);
This code piece did the job I desired.
This is the first time for me to create an mobile apps. Im using android studio for develop it. I want to ask how to create a thick left border in cardView? im confused. I find out in this forum and there are no answers
Can somebody help me?
I want to create a card like this
card examples
But what i code just like this
what i just created
<android.support.v7.widget.CardView
android:id="#+id/cardView"
style="#style/ListStyle"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.219">
</android.support.v7.widget.CardView>
The style too if needed
<style name="ListStyle" parent="Theme.AppCompat.NoActionBar">
<item name="cardCornerRadius">2dp</item>
<item name="cardElevation">2dp</item>
<item name="contentPaddingBottom">24dp</item>
<item name="contentPaddingTop">24dp</item>
<item name="contentPaddingLeft">16dp</item>
<item name="contentPaddingRight">16dp</item>
<item name="cardBackgroundColor">#color/putih</item>
</style>
Thanks for helping me:)
Use this code :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
style="#style/RippleStyleBlack"
android:layout_width="match_parent"
android:layout_marginTop="5dp"
android:layout_height="wrap_content">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/seeall_lead_list"
android:layout_width="match_parent"
android:layout_height="90dp"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true">
<android.support.v7.widget.CardView
android:layout_margin="5dp"
android:layout_width="match_parent"
android:layout_height="84dp"
android:layout_centerInParent="true"
android:elevation="10dp"
>
<View
android:layout_width="20dp"
android:layout_height="match_parent"
android:background="#D64D4D">
</View>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginLeft="25dp"
android:layout_marginTop="20dp"
android:src="#drawable/icon_image"
/>
<TextView
android:id="#+id/lead_NameNew"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginStart="114dp"
android:text="Add List"
android:textAlignment="center"
android:textSize="30dp" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
</RelativeLayout>
I'm having some issues inside a constraint layout where i have a TextView which supports multiple lines. When the TextView is expanded it overlaps with other components inside the constraint layout. Below is the XML layout that i'm using and a GIF to demonstrate.
Any help would be much appreciated.
Demonstration -> https://puu.sh/xPFSF/3f6711a68f.gif
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:background="#color/activity_background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<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:focusableInTouchMode="true"
android:layout_height="0dp">
<android.support.constraint.Guideline
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/leftGuideline"
app:layout_constraintGuide_begin="20dp"
android:orientation="vertical"/>
<android.support.constraint.Guideline
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/rightGuideline"
app:layout_constraintGuide_end="20dp"
android:orientation="vertical"/>
<TextView
android:id="#+id/subject"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="#string/subject"
android:layout_marginTop="20dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="#id/leftGuideline"
app:layout_constraintEnd_toEndOf="#id/rightGuideline" />
<EditText
android:id="#+id/message"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="#string/your_message"
android:layout_marginTop="20dp"
android:minLines="2"
app:layout_constraintTop_toBottomOf="#id/subject"
app:layout_constraintStart_toStartOf="#id/leftGuideline"
app:layout_constraintEnd_toEndOf="#id/rightGuideline" />
<Button
android:id="#+id/sendMessageButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="#string/send_message"
style="#style/button_main"
app:layout_constraintVertical_bias="1"
app:layout_constraintTop_toBottomOf="#id/message"
app:layout_constraintStart_toStartOf="#id/leftGuideline"
app:layout_constraintBottom_toTopOf="#+id/saveDraftButton"
app:layout_constraintEnd_toEndOf="#id/rightGuideline" />
<TextView
android:id="#+id/saveDraftButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/save_draft"
android:layout_marginBottom="10dp"
android:drawableStart="#drawable/icon_arrow"
android:gravity="center_vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="#id/leftGuideline"
app:layout_constraintEnd_toEndOf="#id/rightGuideline" />
</android.support.constraint.ConstraintLayout>
</ScrollView>
Edit: Removed RecyclerView as it wasn't necessary.
As requested, button_main style:
<style name="button_main" parent="#style/button">
<item name="android:textColor">#color/button_main_stateful_text</item>
<item name="android:background">#drawable/primary_action_button</item>
<item name="android:textSize">#dimen/h5_size</item>
<item name="android:textAllCaps">false</item>
</style>
button_main_stateful_text & primary_action_button are just two selectors that switch between colours.
scottazord adding
app:layout_constraintBottom_toTopOf="#+id/sendMessageButton"
to EditText should solve your problem.
the EditText full code is
<EditText
android:id="#+id/message"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="your message"
android:layout_marginTop="20dp"
android:minLines="2"
app:layout_constraintTop_toBottomOf="#id/subject"
app:layout_constraintStart_toStartOf="#id/leftGuideline"
app:layout_constraintEnd_toEndOf="#id/rightGuideline"
app:layout_constraintBottom_toTopOf="#+id/sendMessageButton"/>
now this should solve your issue