⑴ android viewpager和fragment實現頂部導航界面滑動效果為什麼需要三個fragment
實現頂部效果的話,不一定要3個的,兩個應該也可以有效果的,viewpager可以提前載入fragment
⑵ android 微信導航欄的滑動效果(滑塊隨著頁面滑動也跟著平滑)怎麼做,大神有demo嗎
簡單的Actionbar 搭配ViewPager。你在eclipse中new 一個Activity,選擇blank activity,然後在Navigation type選擇ActionBar tabs with ViewPager,就會幫你生成一個demo了。
⑶ android中怎麼使我自定義的導航欄隨著最頂部的狀態欄滑動隱藏呢
狀態欄滑動隱藏已經可以了,就是不知道怎麼隨著滑動使導航欄也跟著滑動,重點是自定義的不是自帶的。
⑷ 小程序 頂部導航欄怎樣做成可滑動
android4.0隱藏下方的導航欄用requestWindowFeature(Window.
⑸ 如何實現手機上能左右滑動的頁面導航菜單
Android上有一個控制項叫做ViewPager,該控制項可以根據item的多少實現左右滑動的效果。Android上還有一個東西叫做Fragment,這是一個依賴於Activity而又獨立的頁面。綜合這兩個控制項的特性,可以使用ViewPager+Fragment的方式,即在ViewPager里嵌入Fragment的方式,實現頁面左右滑動的效果。
⑹ android listview如何按時加滾動到頂部
listview的一些方法:
1.public
void setSelection (int position)
position位置的item置頂(即position位置的item到listview的最頂端),但是,沒有從原來位置到頂端的滑動效果。
2.public
void setSelectionFromTop (int position, int y)
與setSelection 類似。setSelection(position)就是setSelectionFromTop (position,0)
選中position指定的項目,並將所選項置於距離ListView頂端y像素的位置
參數
position 需要選中的項目的索引(從0開始)
y
距離ListView(包括間隙)頂端的位置
3.public
void smoothScrollToPositionFromTop (int position, int
offset)
平滑滾動到指定的適配器位置。 指定位置的視圖會滾動到相對頂邊偏移 offset 像素的位置顯示。
如果無法做到(比如該偏移量會使首尾條目超越列表邊緣),會滾動到盡量接近的位置。
參數
position 滾動到的位置
offset 滾動結束時,指定 position 條目距離視圖頂部的像素數
當offset=0時,可以把position位置的item置頂,而且帶有滑動效果,即會從原來位置輕輕滑動到最頂
端位置。
測試:
可以順利滾動,返回滾動也很順利,滑動順暢
4、public void
smoothScrollToPositionFromTop(int position)
參數:
position 滾動到的位置
帶有滑動效果的滾動到指定位置。
如何判斷其內容已滾動到最頂部或者最底部看
getListView().setOnScrollListener(new OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
if(firstVisibleItem==0){
Log.e("log", "滑到頂部");
}
if(visibleItemCount+firstVisibleItem==totalItemCount){
Log.e("log", "滑到底部");
}
}
});
平滑的滾動listview到一個指定位
package com.android.contacts.widget;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.ListView;
public class AutoScrollListView extends ListView {
private static final
float PREFERRED_SELECTION_OFFSET_FROM_TOP = 0.33f;
private int
mRequestedScrollPosition = -1;
private boolean
mSmoothScrollRequested;
public
AutoScrollListView(Context context) {
super(context);
}
public
AutoScrollListView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public
AutoScrollListView(Context context, AttributeSet attrs, int
defStyle) {
super(context, attrs, defStyle);
}
public void
requestPositionToScreen(int position, boolean smoothScroll) {
mRequestedScrollPosition = position;
mSmoothScrollRequested = smoothScroll;
requestLayout();
}
@Override
protected void
layoutChildren() {
super.layoutChildren();
if (mRequestedScrollPosition == -1) {
return;
}
final int position =
mRequestedScrollPosition;
mRequestedScrollPosition = -1;
int firstPosition = getFirstVisiblePosition() +
1;
int lastPosition =
getLastVisiblePosition();
if (position >= firstPosition &&
position <= lastPosition) {
return; //
Already on screen
}
final int offset = (int) (getHeight() *
PREFERRED_SELECTION_OFFSET_FROM_TOP);
if (!mSmoothScrollRequested) {
setSelectionFromTop(position, offset);
// Since
we have changed the scrolling position, we need to redo child
layout
// Calling
"requestLayout" in the middle of a layout pass has no effect,
// so we
call layoutChildren explicitly
super.layoutChildren();
} else {
// We will
first position the list a couple of screens before or after
// the new
selection and then scroll smoothly to it.
int
twoScreens = (lastPosition - firstPosition) * 2;
int
preliminaryPosition;
if
(position < firstPosition) {
preliminaryPosition = position + twoScreens;
if (preliminaryPosition >=
getCount()) {
preliminaryPosition = getCount() - 1;
}
if (preliminaryPosition <
firstPosition) {
setSelection(preliminaryPosition);
super.layoutChildren();
}
} else
{
preliminaryPosition =
position - twoScreens;
if (preliminaryPosition <
0) {
preliminaryPosition = 0;
}
if
(preliminaryPosition > lastPosition) {
setSelection(preliminaryPosition);
super.layoutChildren();
}
}
smoothScrollToPositionFromTop(position, offset);
}
}
}
⑺ 安卓開發 上面的導航欄和底部的導航欄 控制項實現的
在Layout裡面自己新建一個xml,裡面把你的導航欄自定義好,然後在你需要用到的地方
<include layout="@layout/head_title" /> 就可以了
⑻ Android應用的tab導航是放在屏幕頂部好還是底部好
Android Design 中說的是放在頂部,而且 Effective 的 Navigation 方式是再配上 ViewPager .因為現在手機屏幕越做越大,單純把 Tab 放在頂上,幾個 Fragment 之間還不好劃著切換會很蛋疼,例子見三星的大部分原廠應用(其實三星做系統也就基本上改UI,深層次改動沒有,所以三星的系統也是'各大廠商修改的 Android 里最趨於穩定的)。而Tab放在下面的好處不必多說,可以讓用戶單手就可以按到並實現切換,例如魅族的 SmartBar,開發者只要反射一個介面方法就可以把Tab放到下面來,還是蠻方便的。
⑼ android中怎樣實現手指向上滑動頂部導航欄從透明變成不透明的
(id)initWithRootViewController:(UIViewController *)rootViewController
{
if (self = [super initWithRootViewController:rootViewController]) {
self.navigationBar.translucent = YES;
}
return self;
}
色調顏色
在我的 UIApplicationDelegate 的子類,我設置導航欄中的色調顏色。我發現色調顏色的 alpha 沒有區別。也就是說,使用 alpha 0.1 不會導致要變得更透亮的欄。
(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[UINavigationBar appearance] setTintColor:[UIColor greenColor]];
}
邊緣
在我的內容視圖控制器中,我將設置邊緣為 UIRectEdgeNone 這樣頂部的導航欄不會砍。如果要使用默認的 UIRectEdgeAll ,導航欄將會永久地蓋頂部的我的內容。即使我要住在一起這種異常, UIRectEdgeAll 仍然不會啟用半透明效果。
(void) viewDidLoad
{
[super viewDidLoad];
self.edgesForExtendedLayout = UIRectEdgeNone;
}
編輯: 試驗與邊緣
@rmaddy 在評論中所指出的廣告問題可能與 edgesForExtendedLayout。我發現綜合教程 edgesForExtendedLayout ,並試圖實現它:
(void) viewDidLoad
{
[super viewDidLoad];
self.edgesForExtendedLayout = UIRectEdgeAll;
self. = YES;
self. = NO;
}
它不工作。首先,那裡是沒有半透明效果。第二,我的內容的頂部被切掉。在上面的代碼與以下示例頁上,神通最初由導航欄和它是很難向滾動。你可以拉下,看到頂部的化身,但當你放開,頁面會自動彈起來,神通將會再次被遮掩。
解決方法 1:
問題是由第三方拉下來刷新視圖EGORefreshTableHeaderView,而普遍地使用了之前的 iOS 6 介紹系統刷新控制引起的。
這種觀點混淆了 iOS 7,讓它認為內容是比真的很高。Ios 6 和
7,我已經有條件地切換到使用UIRefreshControl。現在的導航欄不會砍掉我的內容。我可以使用 UIRectEdgeAll
,使我下面的導航欄的內容走。最後,顯示我的導航欄與較低的 α 要獲得半透明效果色調圖。
// mostly rendant calls, because they're all default
self.edgesForExtendedLayout = UIRectEdgeAll;
self. = YES;
self. = NO;
[[UINavigationBar appearance] setTintColor:[UIColor colorWithWhite:0.0 alpha:0.5]];