我的雇主让我开发一个具有非常具体的 UI 要求的 Android 应用程序。具体来说,我们需要一个看起来与 TabWidget 界面一模一样的界面。但是,将选项卡放在左侧是绝对必须的。我们不会将此应用程序部署到任何 Android 手机,它用于内部设备,因此不会违反 Android 平台可能具有的任何设计考虑因素。
我们已经有了一个工作原型(prototype),它使用焦点监听器和 ListView 的组合来组合我们需要的功能。它不是很漂亮,我们现在还不是很有信心,但它暂时有效。
我们真正想要的是放弃所有原型(prototype) UI 代码,以换取使用内置的 TabWidget。但是,由于 TabWidget 被硬编码为仅适用于顶部的选项卡,因此这并不是一个真正的选择。
所以,我们希望有人有一个补丁,或一组补丁,或者可能是一个自定义类,来处理 TabWidget 功能,而不是在侧面的选项卡?
为了成为顶部的标签而硬编码的特定功能是
private void initTabWidget() {
setOrientation(LinearLayout.HORIZONTAL);
mGroupFlags |= FLAG_USE_CHILD_DRAWING_ORDER;
final Context context = mContext;
final Resources resources = context.getResources();
if (context.getApplicationInfo().targetSdkVersion <= Build.VERSION_CODES.DONUT) {
// Donut apps get old color scheme
if (mLeftStrip == null) {
mLeftStrip = resources.getDrawable(
com.android.internal.R.drawable.tab_bottom_left_v4);
}
if (mRightStrip == null) {
mRightStrip = resources.getDrawable(
com.android.internal.R.drawable.tab_bottom_right_v4);
}
} else {
// Use modern color scheme for Eclair and beyond
if (mLeftStrip == null) {
mLeftStrip = resources.getDrawable(
com.android.internal.R.drawable.tab_bottom_left);
}
if (mRightStrip == null) {
mRightStrip = resources.getDrawable(
com.android.internal.R.drawable.tab_bottom_right);
}
}
// Deal with focus, as we don't want the focus to go by default
// to a tab other than the current tab
setFocusable(true);
setOnFocusChangeListener(this);
}
如果有人有任何信息,我将不胜感激。
最佳答案
我遇到过底部标签的问题。我最终只是复制了所有选项卡背景可绘制对象,并制作了带有状态可绘制对象和文本颜色的按钮,这些按钮看起来像控制主 UI Pane 中的 ViewFlipper 以在 View 之间切换的选项卡。
关于android - android tabwidget 的现有补丁允许左侧的标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3497506/