Android 导航栏实现(仿网易新闻)
请教大家,如何实现类似网易新闻客户端中,最上面“头条,体育,娱乐,财经,科技”等的导航。最好有代码。 --------------------编程问答-------------------- textview+tabhost --------------------编程问答--------------------
你好,如果上面的导航栏用tabhost ,那下面红色框中的功能也有tabhost.一个布局文件中能有两个tabhost吗?
QQ:1520074566,可以QQ交流. --------------------编程问答-------------------- 帮顶了~~~ --------------------编程问答-------------------- 太难看了 --------------------编程问答-------------------- 嗯,不好看。 --------------------编程问答-------------------- 你完全可以写一排button 美工一修饰就看起来像你上面的效果了
而下面就是一个tabhost 加载各种布局就哈了 --------------------编程问答-------------------- 代码里面是用的HorizontalScrollView --------------------编程问答--------------------
--------------------编程问答-------------------- 导航: 在一个FrameLayout中有一个ImageView,通过设置这个ImageView的位置即可实现 (省去美工做很多图片) FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams)imageView.getLayoutParams();
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout android:orientation="vertical" android:id="@id/main"
android:background="#ffecedee" android:layout_width="fill_parent"
android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<include android:id="@id/top_main_bottom" android:layout_width="fill_parent"
android:layout_height="wrap_content" layout="\@layout/top_bottom" />
<TabHost android:id="@id/tabhost" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_below="@id/top_main_bottom">
<FrameLayout android:id="@android:id/tabcontent"
android:paddingBottom="42.0px" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!--tab_news-->
<LinearLayout android:orientation="vertical" android:id="@id/tab_news"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<RelativeLayout android:id="@id/column_navi"
android:background="@drawable/top_column_bg" android:visibility="gone"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<ImageButton android:id="@id/column_to_left"
android:background="#00000000" android:visibility="visible"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5.0px" android:src="@drawable/arr_left"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true" />
<ImageButton android:id="@id/column_to_right"
android:background="#00000000" android:visibility="visible"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_marginRight="5.0px" android:src="@drawable/arr_right"
android:layout_alignParentRight="true"
android:layout_centerVertical="true" />
<HorizontalScrollView android:id="@id/column_scrollview"
android:scrollbars="none" android:fadingEdge="vertical"
android:layout_width="fill_parent" android:layout_height="35.0px"
android:layout_toLeftOf="@id/column_to_right"
android:layout_toRightOf="@id/column_to_left">
<FrameLayout android:layout_gravity="center_vertical"
android:paddingLeft="5.0px" android:paddingTop="3.0px"
android:paddingRight="5.0px" android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView android:id="@id/column_slide_bar"
android:layout_width="49.0px" android:layout_height="29.0px" />
<LinearLayout android:layout_gravity="center_vertical"
android:id="@id/column_title_layout" android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</FrameLayout>
</HorizontalScrollView>
</RelativeLayout>
<FrameLayout android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView android:id="@id/top_weight_bg_id"
android:background="@drawable/top_weight_bg" android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<ListView android:id="@id/itemlist" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:listSelector="@drawable/listview_selector"
android:cacheColorHint="#00000000" android:divider="@drawable/list_divider_line" />
</FrameLayout>
</LinearLayout>
<LinearLayout android:orientation="vertical" android:id="@id/tab_topic"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<ListView android:id="@id/topic_list" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:listSelector="@drawable/listview_selector"
android:cacheColorHint="#00000000" android:divider="@drawable/list_divider_line" />
</LinearLayout>
<LinearLayout android:gravity="center"
android:orientation="vertical" android:id="@id/tab_images"
android:background="@drawable/pictures_bg" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<GridView android:id="@id/photosetgridview"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:layout_marginLeft="5.0px" android:layout_marginRight="5.0px"
android:horizontalSpacing="5.0px" android:verticalSpacing="5.0px"
android:numColumns="2" />
</LinearLayout>
<LinearLayout android:orientation="vertical" android:id="@id/tab_notes"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<include android:layout_width="fill_parent"
android:layout_height="fill_parent" layout="\@layout/comments" />
</LinearLayout>
<LinearLayout android:orientation="vertical" android:id="@id/tab_vote"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout android:orientation="vertical"
android:id="@id/vote_image_text" android:layout_width="fill_parent"
android:layout_height="360.0px" xmlns:android="http://schemas.android.com/apk/res/android" />
<ImageView android:background="@drawable/top_weight_bg"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_alignTop="@id/vote_image_text" />
</RelativeLayout>
</LinearLayout>
<include android:layout_gravity="center"
android:layout_width="fill_parent" android:layout_height="fill_parent"
layout="\@layout/loadingbar" />
</FrameLayout>
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabWidget android:id="@android:id/tabs"
android:background="@drawable/tab_bg" android:layout_width="fill_parent"
android:layout_height="42.0px" android:layout_alignParentBottom="true" />
<ImageView android:id="@id/tab_front_bg"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:src="@drawable/tab_front_bg" android:layout_alignLeft="@android:id/tabs"
android:layout_alignBottom="@android:id/tabs" />
<ImageView android:id="@id/tab_bg_bg" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:src="@drawable/bottom_weight_bg"
android:layout_above="@android:id/tabs" />
</RelativeLayout>
</TabHost>
</LinearLayout>
lp.leftMargin = 20?;
imageView.setLayoutParams(lp);
imageView.invalidate();
选项卡: 看这位同学的http://www.cnblogs.com/xiaoguang123/archive/2011/09/26/2191825.html 有代码下载
--------------------编程问答-------------------- 这个事基础了吧 --------------------编程问答-------------------- 我了个去,我敢打赌这绝对是textview或者imageview,加了动画效果和美化就是了。你不信反编译看看。 --------------------编程问答-------------------- 楼主可以尝试把那个程序反编译一下,看看他的布局是如何实现的 --------------------编程问答-------------------- 用Fragment --------------------编程问答-------------------- do you know "Fragment"? --------------------编程问答-------------------- 那之后怎么在fragment中创建lisiView呢? --------------------编程问答--------------------
难道fragment你没有用过?
--------------------编程问答--------------------
那之后怎么在fragment中创建lisiView呢?
用Fragment
难道fragment你没有用过?
如果继承ListFragment,那么
FragmentManager fm;
FragmentTransaction ft;
fm = getFragmentManager();
ft = fm.beginTransaction();
在这句代码,replace就会报错,要怎么改呢?
ft.replace(R.id.content, new Fragment_news());
ft.commit();
新手求教。 --------------------编程问答--------------------
那之后怎么在fragment中创建lisiView呢?
用Fragment
难道fragment你没有用过?
肯定用这个的 我自己现在就用这个
补充:移动开发 , Android