I am using SnackBar
for single line message for related operation.
Snackbar snackBar;
public void showSnackBar(View view){
snackBar = Snackbar.make(view, "Searching for GPS", Snackbar.LENGTH_INDEFINITE);
snackBar.show();
}
In the method isGPSEnabled
, i use the method showSnackBar
if(Helper.isGPSEnabled(this)){
showSnackBar(findViewById(android.R.id.content));
}
But I got this,
Why SnackBar
allow some space from bottom bar ?
Edit
The layout file :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/content"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/edit_text"
android:divider="@android:drawable/divider_horizontal_textfield"
android:addStatesFromChildren="true">
<LinearLayout android:id="@+id/container"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingEnd="0dip"
/>
<AutoCompleteTextView android:id="@+id/edit"
android:completionThreshold="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:layout_gravity="center_vertical"
/>
</LinearLayout>
Please check android.R.id.content
view in your layout file. SnackBar will be shown at the bottom of this view if it is FrameLayout. If you have added padding try removing it.
Can help you better, if you share the layout code.
change 'content' Linear layout_height = "match_parent"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/content"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:drawable/edit_text"
android:divider="@android:drawable/divider_horizontal_textfield"
android:addStatesFromChildren="true">
add answer. try this.
in xml linear id change
android:id="@+id/content" to android:id="@+id/parentLinear"
and code
LinearLayout linear = (LinearLayout)findViewById(R.id.parentLinear);
Snackbar.make(linear, "Searching for GPS", Snackbar.LENGTH_INDEFINITE).show();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.