Hello to everyone in this forum,
i'm new to android-development and i have a question:
i'm trying to create a rounded button,i found a tutorial that descibles the android:background attribute for the Button element for the layout files. So i created the buttonshape.xml in the drawables folder and have the following layout file:
Now my problem is that i'm not able to set a padding for the Button, no matter which attribute i set i get no padding and the app stops directly after starting it. Here is the code of the drawable/buttonshape.xml file:
I don't understand what i'm doing wrong so the app isn't even starting... but i get no errors when building it... please help a lost soul.
best regards,
workbench
i'm new to android-development and i have a question:
i'm trying to create a rounded button,i found a tutorial that descibles the android:background attribute for the Button element for the layout files. So i created the buttonshape.xml in the drawables folder and have the following layout file:
Code:
<?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:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp">
<Button
android:id="@+id/date_from_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="onButtonDateFrom"
android:background="@drawable/buttonshape"
android:text="@string/datum_from_button" />
<Button
android:id="@+id/date_to_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="onButtonDateTo"
android:text="@string/datum_to_button" />
</LinearLayout>
<DatePicker
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/time_from_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="onButtonTimeFrom"
android:text="@string/time_from_button" />
<Button
android:id="@+id/time_to_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="onButtonTimeTo"
android:text="@string/time_to_button" />
</LinearLayout>
<DatePicker
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/search_start"
android:layout_gravity="center_horizontal"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/search_start"/>
</FrameLayout>
</ScrollView>
</LinearLayout>
Now my problem is that i'm not able to set a padding for the Button, no matter which attribute i set i get no padding and the app stops directly after starting it. Here is the code of the drawable/buttonshape.xml file:
Code:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<corners
android:radius="23dp"
/>
<solid
android:color="#FF0000"
/>
<stroke
android:width="2dp"
android:color="#878787"
/>
<padding
android:left="5dp"
android:top="5dp"
android:right="5dp"
android:bottom="5dp"
/>
</shape>
best regards,
workbench