2015-05-16 4 views
3

Я здесь новый. Мне нужна твоя помощь, потому что я ничего не знаю. Например, я помещал панель инструментов для своего приложения, а не панель действий в верхней части экрана ... теперь я хочу разместить панель инструментов внизу ... так как я могу это сделать? Панель инструментов правильная, и она совместима с Android 4.0+? Благодарим вас за ответы.Как добавить панель инструментов в нижней части экрана?

EDIT: это код mainactivity.xml который показывает панель инструментов в верхней части экрана:

<android.support.v4.widget.DrawerLayout 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:id="@+id/drawer_layout" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 


    <LinearLayout 
     android:id="@+id/container_toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 

     <include 
      android:id="@+id/toolbar" 
      layout="@layout/toolbar" /> 
    </LinearLayout> 

    <FrameLayout 
     android:id="@+id/container_body" 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" /> 

<ListView 
    android:id="@+id/drawer" 
    android:layout_width="320dp" 
    android:layout_height="match_parent" 
    android:layout_gravity="start" 
    android:background="#FFF" 
    android:choiceMode="singleChoice" 
    android:divider="@android:color/transparent" 
    android:dividerHeight="0dp" /> 

+0

Если у вас есть что-нибудь попробовать. поместите некоторый код, что вы попробовали. –

+0

@BoradHardik см. Мое правление – nani

ответ

1

Edited

<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=".HomeActivity"> 

<android.support.v7.widget.Toolbar 
    android:id="@+id/toolbar" 
    android:layout_width="match_parent" 
    android:layout_height="?attr/actionBarSize" 
    android:layout_alignParentBottom="true" 
    android:background="?attr/colorPrimary" /> 

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 


    <FrameLayout 
     android:id="@+id/container_body" 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" /> 

    <ListView 
     android:id="@+id/drawer" 
     android:layout_width="320dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:background="#FFF" 
     android:choiceMode="singleChoice" 
     android:divider="@android:color/transparent" 
     android:dividerHeight="0dp" /> 
</android.support.v4.widget.DrawerLayout> 

Привет, я им plemented таким образом Вот это деятельность

public class HomeActivity extends AppCompatActivity { 

private Toolbar toolbar; 
@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_home); 
    toolbar = (Toolbar) findViewById(R.id.toolbar); 
    setSupportActionBar(toolbar); 
    getSupportActionBar().setDisplayHomeAsUpEnabled(true); 
    getSupportActionBar().setDisplayShowHomeEnabled(true); 
} 

@Override 
public boolean onCreateOptionsMenu(Menu menu) { 
    // Inflate the menu; this adds items to the action bar if it is present. 
    getMenuInflater().inflate(R.menu.menu_home, menu); 
    return true; 
} 

@Override 
public boolean onOptionsItemSelected(MenuItem item) { 
    // Handle action bar item clicks here. The action bar will 
    // automatically handle clicks on the Home/Up button, so long 
    // as you specify a parent activity in AndroidManifest.xml. 
    int id = item.getItemId(); 

    //noinspection SimplifiableIfStatement 
    if (id == R.id.action_settings) { 
     return true; 
    } 

    return super.onOptionsItemSelected(item); 
} 

}

Вот это XML

<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=".HomeActivity"> 


<android.support.v7.widget.Toolbar 
    android:id="@+id/toolbar" 
    android:layout_width="match_parent" 
    android:layout_height="?attr/actionBarSize" 
    android:layout_alignParentBottom="true" 
    android:background="?attr/colorPrimary" /> 

Вот код styles.xml

<resources> 

<!-- Base application theme. --> 
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> 
    <!-- Customize your theme here. --> 
</style> 
+0

можно использовать две панели инструментов? – nani

+0

Я пробовал это с двумя панелями инструментов, которые не сработали, но визуальный редактор показывает два. – sector11

+0

Я тоже пробовал, но редактор помещает toobar рядом, а не внизу – nani

0

Я думаю, что это возможно для Android 4.4 и 5.

Если и попробовать это:

<menu 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" 
tools:context="com.example.toolbar.MainActivity" > 
Смежные вопросы