- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我在这个布局中使用 ActionBar.Tab setCustomView() 方法:
<?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="fill_parent"
android:background="@color/background_grey" >
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Test Tab"
android:textColor="@color/background_dark_green"/>
</RelativeLayout>
这是我设置 ActionBar 的函数:
public void setActionBar()
{
ActionBar actionBar = getSupportActionBar();
//actionBar.hide();
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowTitleEnabled(false);
//set action bar navigation mode
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
//set tabs
//home tab
Tab tab = actionBar.newTab().setText(TAB_HOME).setTabListener(new PicoTabListener<StartFragment>(this, StartFragment.class));
tab.setCustomView(R.layout.tab_background);
actionBar.addTab(tab);
//events tab
tab = actionBar.newTab().setText(TAB_EVENTS).setTabListener(new PicoTabListener<EventsFragment>(this, EventsFragment.class));
actionBar.addTab(tab);
//enter event code
tab = actionBar.newTab().setText(TAB_CODE).setTabListener(new PicoTabListener<EnterCodeFragment>(this, EnterCodeFragment.class));
actionBar.addTab(tab);
}
和我的 Activity 布局:
<?xml version="1.0" encoding="utf-8"?>
<!-- This is the main layout of the application -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragment_basic_root"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/background_dark_green" >
</RelativeLayout>
结果接缝看起来像这样(带灰色背景的左上角选项卡):
如何使我的自定义 View 填充整个选项卡并正常工作?
我正在使用适用于 Android 2.3 的 v7 支持包
最佳答案
我自己刚遇到这个问题并想出了解决方案。您应该为清除背景和填充的 tabview 创建一个样式,并将其用于您的主题。
样式.xml:
<style name="Custom.ActionBar.TabView.Empty" parent="@style/Widget.AppCompat.ActionBar.TabView">
<item name="android:background">@null</item>
<item name="android:padding">0dp</item>
</style>
主题.xml:
<style name="Theme.Custom" parent="@style/Theme.AppCompat.Light">
<item name="android:actionBarTabStyle">@style/Custom.ActionBar.TabView.Empty</item>
<item name="actionBarTabStyle">@style/Custom.ActionBar.TabView.Empty</item>
</style>
关于Android ActionBar.Tab setCustomView() 不 fill_parent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19754804/
如果 fill_parent 已过期,为什么 android 创建项目,给一个带有 fill_parent 而不是 match_parent 的 main.xml? 我读过很多次,您应该使用 matc
我的父线性布局 所以我有这个类 GifWebView import android.content.Context; import java.io.InputStream; impo
引入 match_parent 和弃用 fill_parent 的原因是什么,因为两者意思相同。这种变化不会妨碍向后兼容吗? 最佳答案 使用 match_parent 而不是 fill_parent
你好。这是我的布局 当我运行它时, ListView 占据全屏。我想要的是 ListView 是全屏的,除了按钮区域,没有提到 dp。谢谢 最佳答案 @mnish 非常正确,除
我正在使用谷歌在 IO 上分发的新 10.1 galaxy tab。我是 android 布局的新手,但 eclipse 中的图形布局看起来不错,但我的应用程序未填充选项卡上的父项。 这是我的main
我的对话框布局包含: 对话框仍然与其内容一样小。 我必须做的: dialog.getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams
如果我使用的是 Dialog,那么 Dialog.getWindow().setLayout(LayoutParams.FILL_PARENT , LayoutParams.FILL_PARENT);
我想通过 layoutInflater 将一个布局放入另一个布局。 这是 main_layout.xml 文件: 这是 vitrin_layout.xml 文件: 最后是我主
首先不得不说this似乎与我的问题相同。但事实并非如此。 我有这个 HTML: .parent{ border: 1px solid gray; width: 70%; } .title{
我有一个自定义的 ViewGroup,它从 xml 布局扩展一个 ListView。列表项布局是从另一个 xml 文件扩展而来的。所有 View 都设置为 fill_parent。 ListView
我有一个简单的布局: 但我的 TextView 并没有占据所有的宽度,即使我做了 fill_parent。我怎样才能使它具有完整尺寸,而不仅仅是内容的尺寸? 最佳答案 使外部 LinearLay
这个问题在这里已经有了答案: What is the difference between match_parent and fill_parent? (17 个答案) 关闭 8 年前。 现在我在整
我正在尝试在 Android 中创建这个简单的布局。 A 应换行以适合其内容并left|center_vertical 对齐。 B 应尽可能扩展,填满所有空白区域。 C 应该是右对齐的,换行以填充它的
如何在 xml 中使用 LinearLayout height half fill_parent? 我想对高度做类似的事情。 最佳答案 我只想用 1 个 linearLayout 半
我有一个带有单行的简单 TextView。我想将高度设置为 match_parent/fill_parent,但 Android 的行为只是 wrap_content。 有没有办法强制 TextVie
Android 开发者指南 Creating a Custom Dialog指定开始的布局: 如果我使用这段代码,我会得到一个位于屏幕中央的对话框,每侧都有大约 40 像素的底层 View 可见。
首先,我是 Android 开发的新手,所以这可能是一个简单的问题,但我真的无法让它工作。 我有以下布局。
Android 中的可绘制形状使用 fill_parent 来确定其大小是否有效? 编辑 这用于 ImageButton View 的背景。我希望按钮的图标后面有一个圆圈,但我并不总是知道按钮
我试图让我的 TextView layout_width 填充父抛出代码。这是我的代码: TextView WatchMovieTitle; private void PrintTheMovieA
在对 SO 和谷歌进行了大量研究之后,我还没有看到任何人遇到与我遇到的问题完全相同的问题,所以这里是: 我最近重新设计了一个 Android 应用程序的整个 UI。在大多数情况下,我只对每个屏幕进行了
我是一名优秀的程序员,十分优秀!