Browse Source

Toolbar fix

master
DF1E 10 years ago
parent
commit
7d9f382333
  1. 18
      app/src/main/java/acr/browser/lightning/activity/SettingsActivity.java
  2. 14
      app/src/main/res/layout/settings.xml
  3. 23
      app/src/main/res/layout/toolbar_settings.xml

18
app/src/main/java/acr/browser/lightning/activity/SettingsActivity.java

@ -4,7 +4,11 @@ @@ -4,7 +4,11 @@
package acr.browser.lightning.activity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import java.util.ArrayList;
import java.util.List;
@ -18,7 +22,19 @@ public class SettingsActivity extends ThemableSettingsActivity { @@ -18,7 +22,19 @@ public class SettingsActivity extends ThemableSettingsActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// TODO: set up ToolBar
// this is a workaround for the Toolbar in PreferenceActitivty
ViewGroup root = (ViewGroup) findViewById(android.R.id.content);
LinearLayout content = (LinearLayout) root.getChildAt(0);
LinearLayout toolbarContainer = (LinearLayout) View.inflate(this, R.layout.toolbar_settings, null);
root.removeAllViews();
toolbarContainer.addView(content);
root.addView(toolbarContainer);
// now we can set the Toolbar using AppCompatPreferenceActivity
Toolbar toolbar = (Toolbar) toolbarContainer.findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
@Override

14
app/src/main/res/layout/settings.xml

@ -1,14 +0,0 @@ @@ -1,14 +0,0 @@
<?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">
<include layout="@layout/toolbar_settings" />
<fragment
android:name="acr.browser.lightning.fragment.GeneralSettingsFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:tag="settingsFragment" />
</LinearLayout>

23
app/src/main/res/layout/toolbar_settings.xml

@ -1,11 +1,18 @@ @@ -1,11 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?toolbarSettingsBackground"
android:elevation="2dp"
android:minHeight="?attr/actionBarSize"
custom:contentInsetEnd="0dp"
custom:contentInsetStart="0dp" />
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?toolbarSettingsBackground"
android:elevation="2dp"
android:minHeight="?attr/actionBarSize"
custom:contentInsetEnd="0dp"
custom:contentInsetStart="0dp" />
</LinearLayout>
Loading…
Cancel
Save