android android-actionbar android-4.0

android - ¿Cómo puedo forzar que la barra de acción esté en la parte inferior de ICS?



android-actionbar android-4.0 (5)

Intenté agregar la línea en el manifiesto de la aplicación, como se describe en los documentos, pero hasta ahora no lo he conseguido.

Me funcionó en este proyecto de muestra . Aquí está el manifiesto:

<?xml version="1.0" encoding="utf-8"?> <manifest package="com.commonsware.android.actionbarbc" xmlns:android="http://schemas.android.com/apk/res/android"> <application android:hardwareAccelerated="true" android:icon="@drawable/cw" android:label="@string/app_name"> <activity android:label="@string/app_name" android:name=".InflationDemo" android:uiOptions="splitActionBarWhenNarrow"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="11" /> <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:xlargeScreens="true" /> </manifest>

Además, noté que en mi Galaxy Nexus, que ejecuta ICS, la aplicación de mensajería tiene la barra de acción en la parte inferior y nada más que el título en la parte superior, por lo que debe ser posible obligar a la barra de acción a estar en la parte inferior.

Si se refiere a la lista de conversaciones, esa es la ActionBar de ActionBar en la parte superior e inferior, usando splitActionBarWhenNarrow y el siguiente código de configuración:

private void setupActionBar() { ActionBar actionBar = getActionBar(); ViewGroup v = (ViewGroup)LayoutInflater.from(this) .inflate(R.layout.conversation_list_actionbar, null); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setCustomView(v, new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.WRAP_CONTENT, Gravity.CENTER_VERTICAL | Gravity.RIGHT)); mUnreadConvCount = (TextView)v.findViewById(R.id.unread_conv_count); }

Ice Cream Sandwich (Android 4.0) agrega la opción de tener la Action Bar en la parte inferior de la pantalla en los teléfonos, y eso es algo que me encantaría tener en una aplicación mía. Los docs mencionan uiOptions="splitActionBarWhenNarrow" para cuando desee algo, es decir, pestañas, en la parte superior y accesos directos de la Action Bar en la parte inferior. Intenté agregar la línea en el manifiesto de la aplicación, como se describe en los documentos, pero hasta ahora no lo he conseguido.

Aquí hay un ejemplo:

Además, noté que en mi Galaxy Nexus, que ejecuta ICS, la aplicación de mensajería tiene la Action Bar la parte inferior y nada más que el título en la parte superior, por lo que debe ser posible obligar a la Action Bar a estar en la parte inferior.

¿Algunas ideas?


Bueno, no puedes obligar a permanecer en la parte inferior de las tabletas, pero si lo haces, puedes hacerlo a través del manifiesto. pero puedes hacer algo es similar a la barra inferior y superior. En este ejemplo, le mostraré cómo usar merge para hacerlo fácilmente sin la necesidad de usar android ActionBar.

Lo primero que debe crear es su main_activity.xml en mi caso el main_activity.xml solo contiene ImageView en RelativeLayout. aquí está el código.

<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" > <RelativeLayout android:id="@+id/RelativeLayout04" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true"> <include layout="@layout/header" /> </RelativeLayout> <ImageView android:id="@+id/view" android:layout_width="match_parent" android:layout_height="200dp" android:layout_above="@+id/RelativeLayout03" android:layout_below="@+id/RelativeLayout04" android:layout_centerHorizontal="true" android:src="@android:drawable/alert_dark_frame" /> <RelativeLayout android:id="@+id/RelativeLayout03" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true"> <include layout="@layout/tryit" /> </RelativeLayout>

como se puede ver en el código anterior, hay dos fusiones que puse dentro de main_activity.xml definido al final y uno definido en la parte superior. aquí está la barra inferior falsa xml.

<merge xmlns:android="http://schemas.android.com/apk/res/android"> <LinearLayout android:id="@+id/LinearLayout01" android:layout_width="match_parent" android:layout_height="80dp" android:layout_weight="0.14" android:background="@drawable/dock" > <ImageView android:id="@+id/dark" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="0.14" /> <ImageView android:id="@+id/stock" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="0.14" /> <ImageView android:id="@+id/open" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="0.14" /> <ImageView android:id="@+id/border" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="0.15" /> <ImageView android:id="@+id/color" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="0.15" /> </LinearLayout>

Estoy colocando un fondo fijo en LinearLayout y LinearLayout ImageView para onClicks.

y aquí está la barra superior. `

<LinearLayout android:id="@+id/LinearLayout02" android:layout_width="match_parent" android:layout_height="40dp" android:layout_weight="0.14" android:background="@drawable/dock1" android:layout_gravity="top"> <ImageView android:id="@+id/darka" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="0.14" /> <ImageView android:id="@+id/stocka" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="0.14" /> <ImageView android:id="@+id/opena" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="0.14" /> <ImageView android:id="@+id/bordera" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="0.15" /> <ImageView android:id="@+id/colora" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="0.15" /> </LinearLayout>

`

que también copiar pegar desde la barra inferior de arriba. simplemente cambie una cosa de android:layout_alignParentBottom="true" a android:layout_alignParentTop="true" y obtendrá una actionBar en la parte inferior y en la parte superior. en este caso, no necesitarás usar la Barra de acciones, así que te sugiero que uses Theme.Holo.NoActionBar

y aquí está el resultado de la imagen: - http://i.imgur.com/N8uKg6v.png

este es un proyecto en el que estoy trabajando ahora. hecho casi todo, pero aún luchando con el diseño. Espero que mi respuesta te beneficie. por favor vote la respuesta si la encuentra interesante.
atentamente. ~ Kosh


Editar aquí está la imagen :).

de nuevo con mejores resultados :). Lo primero que debe hacer es crear un nombre de diseño, header.xml

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="@dimen/action_bar_height" android:layout_gravity="top" android:baselineAligned="true" android:orientation="horizontal" > <ImageView android:id="@+id/share" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_gravity="start" android:layout_weight=".14" android:background="@drawable/action_bar_left_button" android:src="@drawable/action_bar_glyph_back" /> <ImageView android:id="@+id/bright" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight=".14" android:background="@drawable/action_bar_left_button" android:src="@drawable/action_bar_glyph_lux" /> <ImageView android:id="@+id/rotate" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight=".14" android:background="@drawable/action_bar_left_button" android:src="@drawable/rotate" /> <ImageView android:id="@+id/bright" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight=".14" android:background="@drawable/action_bar_left_button" android:src="@drawable/action_bar_glyph_lux" /> <ImageView android:id="@+id/rotate" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight=".14" android:background="@drawable/action_bar_left_button" android:src="@drawable/rotate" /> <ImageView android:id="@+id/forwa" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight=".14" android:background="@drawable/action_bar_left_button" android:src="@drawable/forward" /> </LinearLayout>

después de eso ve a tu clase MainActivity.class y crea este método.

private void setupActionBar() { ActionBar actionBar = getActionBar(); //actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayShowTitleEnabled(false); ViewGroup v = (ViewGroup)LayoutInflater.from(this) .inflate(R.layout.header, null); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setCustomView(v, new ActionBar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.WRAP_CONTENT, Gravity.CENTER_VERTICAL | Gravity.RIGHT)); }

agregar setupActionBar(); a su actividad onCreate y ejecute su aplicación :).

ahora tiene ActionBar personalizado con divisores e imágenes PS, el divisor está definido en el diseño como un fondo de imagen :).


Estoy usando ActionBarSherlock y tuve un problema similar. Lo resolví poniendo android:uiOptions="splitActionBarWhenNarrow" dentro de la etiqueta <activity> , en lugar de la etiqueta <application> .

Por ejemplo, esto funcionó:

<activity android:name=".my.Activity" android:uiOptions="splitActionBarWhenNarrow"/>

y esto no funcionó

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.slowchop.etc" android:uiOptions="splitActionBarWhenNarrow">


prueba esto...

private View contentView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); contentView = getLayoutInflater().inflate(R.layout.activity_main, null); setContentView(contentView); LinearLayout layout = (LinearLayout) contentView.getParent().getParent(); View view = layout.getChildAt(0); layout.removeViewAt(0); layout.addView(view); }