Issue
I have two buttons with a custom background. However, there is a grey-coloured shadow showing behind the background on the bottom portion.
I've already tried How to remove grey shadow color below FloatingActionButton but it didn't work
This is my code:
green_button_style.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape>
<corners android:radius="50dp" />
<solid android:color="#62741A" />
</shape>
</item>
<item android:state_pressed="false">
<shape>
<corners android:radius="50dp" />
<solid android:color="#8DA626" />
</shape>
</item>
</selector>
This is the button xml
<Button
android:id="@+id/btnDimensions"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:gravity="center"
android:layout_marginLeft="2dp"
android:layout_marginStart="2dp"
android:layout_marginRight="2dp"
android:layout_marginEnd="2dp"
android:padding="10sp"
android:textSize="18sp"
android:textColor="#ffffff"
android:background="@drawable/green_button_style"
android:layout_weight="1"
android:text="Dimensions"
/>
EDIT
here's the entire layout 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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.mridulahuja.kudamm.activities.ComponentDetailsActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/light_green_background"
android:scaleType="fitXY"
android:alpha="0.5"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
android:background="@null"
android:scrollbars="vertical"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<com.mridulahuja.kudamm.tools.SquareImageView
android:id="@+id/imgComponent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:padding="5dp" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:layout_height="10dp"
android:layout_width="match_parent"
/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/txtComponentInfoTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="Description"
android:textColor="#000000"
android:textStyle="bold"
android:textSize="20sp" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.mridulahuja.kudamm.tools.ExpandableTextView
android:id="@+id/txtComponentInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="component info"
android:textColor="#53524E"
android:textSize="20sp" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:layout_height="10dp"
android:layout_width="match_parent"
/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<Button
android:id="@+id/btnDataAtAGlance"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_marginLeft="2dp"
android:layout_marginStart="2dp"
android:layout_marginRight="2dp"
android:layout_marginEnd="2dp"
android:gravity="center"
android:textSize="18sp"
android:textColor="#ffffff"
android:background="@drawable/green_button_style"
android:layout_weight="1"
app:elevation="0dp"
android:text="Details"
/>
<Button
android:id="@+id/btnDimensionsAtAGlance"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:gravity="center"
android:layout_marginLeft="2dp"
android:layout_marginStart="2dp"
android:layout_marginRight="2dp"
android:layout_marginEnd="2dp"
android:padding="10sp"
android:textSize="18sp"
android:textColor="#ffffff"
android:background="@drawable/green_button_style"
android:layout_weight="1"
app:elevation="0dp"
android:text="Dimensions"
/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:layout_height="10dp"
android:layout_width="match_parent"
/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<Button
android:id="@+id/btnDownloadPdfCatalogue"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center"
android:layout_marginLeft="15dp"
android:layout_marginStart="15dp"
android:layout_marginRight="15dp"
android:layout_marginEnd="15dp"
android:padding="10sp"
android:textSize="18sp"
android:textColor="#ffffff"
android:background="@drawable/green_button_style"
app:elevation="0dp"
android:text="PDF Catalogue"
/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:layout_height="10dp"
android:layout_width="match_parent"
/>
</TableRow>
</TableLayout>
</ScrollView>
</RelativeLayout>
Solution
Try adding style to your button:
<Button
android:id="@+id/btnDimensions"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:gravity="center"
android:layout_marginLeft="2dp"
android:layout_marginStart="2dp"
android:layout_marginRight="2dp"
android:layout_marginEnd="2dp"
android:padding="10sp"
android:textSize="14sp"
android:textColor="#ffffff"
android:background="@drawable/green_button_style"
style="?android:attr/borderlessButtonStyle"
android:layout_weight="1"
android:text="Dimensions"
/>
It will give the button with boderless background.
Answered By - Umair
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.