Интерфейс, диалоги, темы, стили, меню
-
andev
- Сообщения: 219
- Зарегистрирован: 13 янв 2012, 17:56
Сообщение
andev » 03 фев 2012, 18:07
Здравствуйте!
Пишу приложение, основная активити состоит из нескольких закладок с возможностью переключения между ними. Заголовки закладок внизу экрана. В зависимости от настроек, их порядок должен меняться.
Скриншот части дизайна (то, как должно выглядеть)

Выглядеть должно одинаково на 2.х, так что использовать стандартный TabWidget не получится.
Кто что посоветует?
-
andev
- Сообщения: 219
- Зарегистрирован: 13 янв 2012, 17:56
Сообщение
andev » 03 фев 2012, 18:18
На данный момент предполагаю что лучше делать отдельным активити и подключать через <include/>, но:
1) должен генерироваться программно, согласно настроек приложения.
2) слабовато представляю как это сверстать, что бы выглядело как надо, ведь тут есть фон, сами кнопки в 2-х состояниях каждая.
-
andev
- Сообщения: 219
- Зарегистрирован: 13 янв 2012, 17:56
Сообщение
andev » 07 фев 2012, 12:28
Ни у кого нет соображений?

-
inn_ko
- Сообщения: 2
- Зарегистрирован: 08 фев 2012, 16:37
Сообщение
inn_ko » 08 фев 2012, 18:56
ActionBar вроде может помочь. Пример (иконки надо заменить на свои):
В
layout
actionbar.xml
Код: Выделить всё
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="@dimen/actionbar_height"
android:layout_marginBottom="2dip">
<ImageView android:id="@+id/actionbar_home_logo"
android:layout_alignParentLeft="true" android:layout_width="wrap_content"
android:layout_height="fill_parent" android:background="@drawable/actionbar_btn"
android:padding="0dip" />
<LinearLayout android:id="@+id/actionbar_actionIcons"
android:layout_width="wrap_content" android:layout_height="@dimen/actionbar_height"
android:layout_alignParentRight="true" android:layout_centerVertical="true"
android:layout_margin="0dp" android:padding="0dp"
android:background="@color/actionbar_separator" />
<ProgressBar android:id="@+id/actionbar_progress"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_toLeftOf="@id/actionbar_actionIcons"
android:layout_centerVertical="true" android:paddingRight="7dip"
android:indeterminateOnly="true" android:visibility="gone"
style="@android:style/Widget.ProgressBar.Small" />
<TextView android:id="@+id/actionbar_title"
android:layout_width="wrap_content" android:layout_height="fill_parent"
android:layout_toRightOf="@id/actionbar_home_logo"
android:layout_toLeftOf="@id/actionbar_progress" android:paddingLeft="10dip"
android:paddingRight="10dip" android:textSize="16dip"
android:textStyle="bold" android:textColor="@color/actionbar_title"
android:lines="1" android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever" />
</RelativeLayout>
actionbar_icon.xml
Код: Выделить всё
<?xml version="1.0" encoding="utf-8"?>
<ImageButton xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/actionbar_item" android:layout_width="44dip"
android:scaleType="fitXY" android:layout_height="44dip"
android:background="@drawable/actionbar_btn" android:padding="4dip"
android:layout_marginLeft="1dip" android:layout_centerVertical="true"
android:singleLine="true" android:visibility="visible" />
И action
ActionBar.java
Код: Выделить всё
import android.app.Activity;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
public class ActionBar extends RelativeLayout {
/**
* Reusable {@link LayoutInflater}
*/
private LayoutInflater mInflater;
/**
* Holds the home-icon logo
*/
private ImageView mLogoView;
/**
* Displays the {@link Activity} text
*/
private TextView mTitleView;
/**
* Represents the progress bar (i.e. busy-icon)
*/
private ProgressBar mProgress;
/**
* Contains the ActionIcons.
*/
private LinearLayout mActionIconContainer;
public ActionBar(Context context, AttributeSet attrs) {
super(context, attrs);
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
RelativeLayout barView = (RelativeLayout) mInflater.inflate(R.layout.actionbar, null);
addView(barView);
mLogoView = (ImageView) barView.findViewById(R.id.actionbar_home_logo);
mProgress = (ProgressBar) barView.findViewById(R.id.actionbar_progress);
mTitleView = (TextView) barView.findViewById(R.id.actionbar_title);
mActionIconContainer = (LinearLayout) barView.findViewById(R.id.actionbar_actionIcons);
}
public void setHomeLogo(int resId) {
setHomeLogo(resId, null);
}
public void setHomeLogo(int resId, OnClickListener onClickListener) {
mLogoView.setImageResource(resId);
mLogoView.setVisibility(View.VISIBLE);
mLogoView.setOnClickListener(onClickListener);
if (onClickListener != null) {
}
}
public void setTitle(CharSequence title) {
mTitleView.setText(title);
}
public void setTitle(int resid) {
mTitleView.setText(resid);
}
public void showProgressBar() {
setProgressBarVisibility(View.VISIBLE);
}
public void hideProgressBar() {
setProgressBarVisibility(View.GONE);
}
/**
* Adds ActionIcons to the ActionBar (adds to the left-end)
*
* @param iconResourceId
* @param onClickListener to handle click actions on the ActionIcon.
*/
public void addActionIcon(int iconResourceId, OnClickListener onClickListener) {
// Inflate
View view = mInflater.inflate(R.layout.actionbar_icon, mActionIconContainer, false);
ImageButton imgButton = (ImageButton) view.findViewById(R.id.actionbar_item);
imgButton.setImageResource(iconResourceId);
imgButton.setOnClickListener(onClickListener);
mActionIconContainer.addView(view, mActionIconContainer.getChildCount());
}
/**
* Remove the action icon from the given index (0 based)
*
* @param index
* @return <code>true</code> if the item was removed
*/
public boolean removeActionIconAt(int index) {
int count = mActionIconContainer.getChildCount();
if (count > 0 && index >= 0 && index < count) {
mActionIconContainer.removeViewAt(index);
return true;
}
return false;
}
/**
* @return <code>true</code> if the progressbar is visible
* @see View#VISIBLE
*/
public boolean isProgressBarVisible() {
return mProgress.getVisibility() == View.VISIBLE;
}
/**
* Set the enabled state of the progress bar.
*
* @param One of {@link View#VISIBLE}, {@link View#INVISIBLE}, or {@link View#GONE}.
*/
private void setProgressBarVisibility(int visibility) {
mProgress.setVisibility(visibility);
}
}
-
andev
- Сообщения: 219
- Зарегистрирован: 13 янв 2012, 17:56
Сообщение
andev » 15 фев 2012, 22:15
damager82, да, на 2.0 не может быть фона (он черный, системный), выше уже фон возможен
inn_ko, спасибо, попробую