我正在创建一个应用程序,它在屏幕底部有五个选项卡,每个选项卡打开一个不同的Activity.
我的选项卡活动扩展了我刚刚阅读的TabActivity,我不应该使用Fragments.
如何更改我的应用程序以使用Fragments?我已经阅读了android.developer.com上的信息,但我仍然不知道如何做到这一点.
我正在我的Android应用程序中实现SlidingTabLayout.我的疑问是,我想在我的滑动标签中实现图标而不是导航文本.我在互联网上搜索任何这样的教程或样本,但没有找到.我还在stackoverflow上搜索了上一个问题:Over Here - SlidingTabLayout with Icons.它提供了一些信息,但并没有真正帮助我.
要清楚.我要求我的标签只包含图标.没有文字.
由于我是这个整个设置的新手,如果您发布正确的代码并附上解释,我将不胜感激.感谢您的时间和精力!
PS 我也听说过Andreaz Stuetz的pagerslidingtabstrip,并想知道这是否更适合我想要的东西......
另外:这是我希望我的滑动标签看起来像.查看此图片的顶部.
编辑:现在LOLLIPOP(与材料设计)已经出来.我使用了一个新的"只有图标"在SLIDING-TAB-LAYOUT
他们的工具栏下面看到了很多应用程序(ANDROID 5.0 ACTION-BAR).是他们实现这个的新方法吗?再次感谢!
android android-icons android-viewpager android-tabs pagerslidingtabstrip
我正在尝试在Android设计库中使用新的TabLayout来创建带有图标的应用栏.
public void setupTabLayout(TabLayout tabLayout) {
tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
tabLayout.setTabGravity(TabLayout.GRAVITY_CENTER);
tabLayout.setupWithViewPager(mViewpager);
tabLayout.getTabAt(0).setIcon(R.drawable.ic_tabbar_library);
tabLayout.getTabAt(1).setIcon(R.drawable.ic_tabbar_recents);
tabLayout.getTabAt(2).setIcon(R.drawable.ic_tabbar_favorites);
tabLayout.getTabAt(3).setIcon(R.drawable.ic_tabbar_notifications);
tabLayout.getTabAt(4).setIcon(R.drawable.ic_tabbar_settings);
}
Run Code Online (Sandbox Code Playgroud)
结果:
请帮我创建类似的app栏:
对不起,我的英语不好.谢谢提前!
目前我正在为我的应用制作UI.我使用Sliding Up Panel和Sliding Tabs (带有实现说明的教程)功能.两者都很好.我甚至设法在一个项目中实现它们,但这就是问题所在 - 当我触摸它们时(Home应该打开它所代表的页面),Home和Event的选项卡没有响应,但是当我在选项卡之间滑动时它们会发生变化.
这是我的布局代码.这就是问题所在.我敢肯定.
<LinearLayout 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"
android:orientation="vertical"
tools:context=".MainActivity">
<include
android:id="@+id/tool_bar"
layout="@layout/tool_bar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
/>
<com.sothree.slidinguppanel.SlidingUpPanelLayout
xmlns:sothree="http://schemas.android.com/apk/res-auto"
android:id="@+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
sothree:umanoPanelHeight="68dp"
sothree:umanoShadowHeight="4dp"
sothree:umanoParalaxOffset="100dp"
sothree:umanoDragView="@+id/dragView">
<!-- MAIN CONTENT -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#ff0000">
<com.ui.test.SlidingTabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/ColorPrimary"/>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_weight="1">
</android.support.v4.view.ViewPager>
</RelativeLayout>
<!-- SLIDING LAYOUT -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#55eeeeee"
android:orientation="vertical"
android:clickable="true"
android:focusable="false"
android:id="@+id/dragView">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="68dp"
android:orientation="horizontal">
<TextView
android:id="@+id/name"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="14sp"
android:gravity="center_vertical"
android:paddingLeft="10dp"/> …
Run Code Online (Sandbox Code Playgroud) 我正在努力设计ActionBar.我的应用程序有一个带有三个选项卡的ActionBar.我试图让选定的标签具有背景颜色,而未选择的标签显示不同的颜色.我正在关注此参考:自定义操作栏.但是所有TAB都显示了选定的颜色.
我的styles.xml
文件如下:
<style name="MyActionBarTabStyle" parent="android:style/Widget.Holo.Light.ActionBar.TabBar">
<item name="android:background">@drawable/tab_background</item>
<item name="android:paddingLeft">32dp</item>
<item name="android:paddingRight">32dp</item>
</style>
<style name="MyActionBarTabBarStyle" parent="android:style/Widget.Holo.Light.ActionBar.TabBar">
<item name="android:background">@drawable/red</item>
</style>
<style name="AppTheme.Light" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">@style/ActionBar.Light</item>
<item name="android:actionBarTabStyle">@style/MyActionBarTabStyle</item>
<item name="android:actionBarTabBarStyle">@style/MyActionBarTabBarStyle</item>
</style>
Run Code Online (Sandbox Code Playgroud)
tab_background只是一个9补丁.我也不确定我是否从正确的parent(parent="android:style/Widget.Holo.Light.ActionBar.TabBar
)继承了操作栏选项卡.我查看了参考资料,发现很难理解样式层次结构
为什么我的标签显示不选择?提前感谢你的帮助.
Android 5.0框架是否具有Material-styled选项卡?我知道在开发预览中,它们仍然是Holo风格的.我想知道5.0是否已使用材质样式选项卡进行更新; 我目前使用PagerSlidingTabStrip作为我的选项卡,但尚未使用Material设计进行更新.
更具体地说,支持库是否包含材料选项卡的实现?在4.x上运行的Play商店有这些标签,但我不确定这是否是谷歌的自定义实现.
我对android很新.现在我构建一个小应用程序.
我需要在2.2中更改android默认查找的外观和感觉.所以,在这里我尝试更改选项卡的背景.你能帮帮我吗?
我喜欢使用xml/style的方式.
这就是我需要的实际输出.
我正在一个包含三个选项卡的屏幕上工作我试图在选项卡中添加一个带有我的文本的图标,我希望图像在文本的上方,它们之间应该有一些空间,这是我的代码.
public class HomeScreen extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
private Toolbar toolbar;
private ViewPager pager;
private ViewPagerAdapter adapter;
private SlidingTabLayout tabs;
private CharSequence Titles[] = {"News", "Most Views", "Chart"};
int Numboftabs = 3;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home_screen);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
//MAhmoud Code Addtion
// getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// getSupportActionBar().setIcon(R.drawable.ic_launcher);
// Creating The …
Run Code Online (Sandbox Code Playgroud) android android-layout android-tabs material-design android-tablayout
我想在屏幕的底部放置标签.为此,我有以下代码:
package info.androidhive.tabsswipe;
import info.androidhive.tabsswipe.adapter.TabsPagerAdapter;
import android.app.ActionBar;
import android.app.ActionBar.Tab;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager;
public class MainActivity extends FragmentActivity implements
ActionBar.TabListener {
private ViewPager viewPager;
private TabsPagerAdapter mAdapter;
private ActionBar actionBar;
// Tab titles
private String[] tabs = { "Top Rated", "Games", "Movies" };
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Initilization
viewPager = (ViewPager) findViewById(R.id.pager);
actionBar = getActionBar();
mAdapter = new TabsPagerAdapter(getSupportFragmentManager());
viewPager.setAdapter(mAdapter) ;
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowTitleEnabled(false);
// Adding Tabs
for (String tab_name : …
Run Code Online (Sandbox Code Playgroud) 我在活动中使用制表符片段,操作栏包含制表符.我想要做的是,无论何时在视图中出现(或重新出现)片段(由用户选择),我都会开始做某事.onResume
在这种情况下我无法使用片段,因为当用户选择另一个标签时,所有标签都不会真正"暂停",因此onResume
不会被调用
我可以使用托管活动中的以下两个事件,但我不想要它们,因为我希望片段应该自己知道这个逻辑并执行该任务.任何的想法?韩国社交协会.
@Override
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
// When the given tab is selected, switch to the corresponding page in the ViewPager.
mViewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
}
Run Code Online (Sandbox Code Playgroud)