java - Android Material design error -
hi learning create material design using tutorial.https://www.youtube.com/watch?v=pmo8evkhjo8&list=plonjj3bvjzw6ctambjz1xd8elus1kxatd&index=3
and in design appbar has padding on sides. can me remove padding , make app real app bar.
app_bar
<?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.toolbar xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#dddd"> </android.support.v7.widget.toolbar>
main activity
<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:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" android:paddingbottom="@dimen/activity_vertical_margin" tools:context=".mainactivity"> <include android:id="@+id/app_bar" layout="@layout/app_bar"/> <textview android:layout_below="@+id/app_bar" android:text="@string/hello_world" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </relativelayout>
maniactivity.java
private toolbar toolbar; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); toolbar = (toolbar) findviewbyid(r.id.app_bar); setsupportactionbar(toolbar); }
in relative layout have put paddings. need remove them.
<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" tools:context=".mainactivity"> <include android:id="@+id/app_bar" layout="@layout/app_bar"/> <textview android:layout_below="@+id/app_bar" android:text="@string/hello_world" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </relativelayout>
check this. there no padding on toolbar. , if want give padding other children make 1 parent layout using linearlayout
orientation
of vertical
, put both toolbar
, relativelayout
it.
Comments
Post a Comment