欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android模仿To圈兒個(gè)人資料界面層疊淡入淡出顯示效果

 更新時(shí)間:2016年07月26日 11:50:56   作者:化作孤島的瓜  
這篇文章主要介紹了Android模仿To圈兒個(gè)人資料界面層疊淡入淡出顯示效果的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下

前幾天做的一個(gè)仿To圈個(gè)人資料界面的實(shí)現(xiàn)效果

下面是To圈的效果Gif圖:

做這個(gè)東西其實(shí)也花了一下午的時(shí)間,一開始思路一直沒理清楚,就開始盲目的去做,結(jié)果反而事倍功半。

以后要吸取教訓(xùn),先詳細(xì)思考清楚其中的邏輯關(guān)系,然后再開始動(dòng)手寫代碼,這樣比較容易理順。

可以看到實(shí)現(xiàn)這個(gè)效果還是不難的,得分成以下三個(gè)步驟:

1:首先要有一個(gè)可拖動(dòng)的詳細(xì)資料布局(下半部分)。

2:上半部分可跟隨移動(dòng)。

3:標(biāo)題欄由隱藏到顯示。

涉及到的技術(shù)點(diǎn)有:

1:屏幕像素密度DP轉(zhuǎn)化。

2:自定義視圖的OnTouchListener事件

3:透明度屬性動(dòng)畫的使用

根據(jù)這三個(gè)要求,設(shè)計(jì)的布局如下:

userinfo_layout.xml

<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@android:color/white"> 
<RelativeLayout 
android:layout_width="match_parent" 
android:layout_height="260dp"> 
<ImageView 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@color/colorTheme"/> 
<LinearLayout 
android:id="@+id/mainheadview" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@drawable/top"></LinearLayout> 
</RelativeLayout> 
<LinearLayout 
android:id="@+id/myscrollLinearlayout" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="#EEEEEE" 
android:clickable="true" 
android:orientation="vertical"> 
<RelativeLayout 
android:layout_width="match_parent" 
android:layout_height="60dp" 
android:background="@android:color/white"> 
<TextView 
android:layout_width="wrap_content" 
android:layout_height="match_parent" 
android:layout_marginLeft="20dp" 
android:gravity="center_vertical" 
android:text="守護(hù)天使" 
android:textColor="#DB4E61" 
android:textSize="14sp"/> 
<TextView 
android:layout_width="wrap_content" 
android:layout_height="match_parent" 
android:layout_alignParentTop="true" 
android:layout_marginEnd="66dp" 
android:layout_toStartOf="@+id/imageView" 
android:gravity="center_vertical" 
android:text="暫時(shí)沒有守護(hù)天使" 
android:textColor="#C0C0C0" 
android:textSize="14sp"/> 
<ImageView 
android:id="@+id/imageView" 
android:layout_width="wrap_content" 
android:layout_height="match_parent" 
android:layout_alignParentEnd="true" 
android:layout_alignParentTop="true" 
android:layout_marginRight="20dp" 
android:paddingBottom="34dp" 
android:paddingTop="34dp" 
android:src="@drawable/ic_more"/> 
</RelativeLayout> 
<View 
android:layout_width="match_parent" 
android:layout_height="1dp" 
android:background="#CCCCCC" 
></View> 
<View 
android:layout_width="match_parent" 
android:layout_height="1dp" 
android:layout_marginTop="15dp" 
android:background="#CCCCCC" 
></View> 
<LinearLayout 
android:layout_width="match_parent" 
android:layout_height="50dp" 
android:background="@android:color/white" 
android:orientation="horizontal"> 
<TextView 
android:layout_width="80dp" 
android:layout_height="match_parent" 
android:layout_marginLeft="15dp" 
android:gravity="center_vertical" 
android:text="昵稱" 
android:textColor="#C0C0C0" 
android:textSize="14sp"/> 
<LinearLayout 
android:layout_width="0dp" 
android:layout_height="match_parent" 
android:layout_marginLeft="10dp" 
android:layout_weight="1" 
android:orientation="vertical" 
> 
<TextView 
android:layout_width="match_parent" 
android:layout_height="0dp" 
android:layout_weight="1" 
android:gravity="center" 
android:textColor="@android:color/black" 
android:textSize="12dp"/> 
<View 
android:layout_width="match_parent" 
android:layout_height="1dp" 
android:background="#CCCCCC" 
></View> 
</LinearLayout> 
</LinearLayout> 
<LinearLayout 
android:layout_width="match_parent" 
android:layout_height="50dp" 
android:background="@android:color/white" 
android:orientation="horizontal"> 
<TextView 
android:layout_width="80dp" 
android:layout_height="match_parent" 
android:layout_marginLeft="15dp" 
android:gravity="center_vertical" 
android:text="個(gè)性簽名" 
android:textColor="#C0C0C0" 
android:textSize="14sp"/> 
<TextView 
android:layout_width="0dp" 
android:layout_height="match_parent" 
android:layout_marginLeft="10dp" 
android:layout_weight="1" 
android:background="@android:color/transparent"/> 
</LinearLayout> 
<View 
android:layout_width="match_parent" 
android:layout_height="1dp" 
android:background="#CCCCCC" 
></View> 
<View 
android:layout_width="match_parent" 
android:layout_height="1dp" 
android:layout_marginTop="15dp" 
android:background="#CCCCCC" 
></View> 
<LinearLayout 
android:layout_width="match_parent" 
android:layout_height="100dp" 
android:background="@android:color/white" 
android:orientation="vertical"> 
<TextView 
android:layout_width="match_parent" 
android:layout_height="35dp" 
android:layout_marginLeft="15dp" 
android:gravity="center_vertical" 
android:text="個(gè)人相冊(cè)" 
android:textColor="#C0C0C0" 
android:textSize="14sp"/> 
<View 
android:layout_width="match_parent" 
android:layout_height="1dp" 
android:background="#CCCCCC" 
></View> 
</LinearLayout> 
<View 
android:layout_width="match_parent" 
android:layout_height="1dp" 
android:background="#CCCCCC" 
></View> 
<View 
android:layout_width="match_parent" 
android:layout_height="1dp" 
android:layout_marginTop="15dp" 
android:background="#CCCCCC" 
></View> 
<LinearLayout 
android:layout_width="match_parent" 
android:layout_height="120dp" 
android:background="@android:color/white" 
android:orientation="vertical"> 
<TextView 
android:layout_width="match_parent" 
android:layout_height="30dp" 
android:layout_marginLeft="15dp" 
android:gravity="center_vertical" 
android:text="私房視頻" 
android:textColor="#DB4E61" 
android:textSize="14sp"/> 
<TextView 
android:layout_width="match_parent" 
android:layout_height="20dp" 
android:layout_marginLeft="15dp" 
android:gravity="start" 
android:text="別人每查看你的一個(gè)私房視頻,你講獲得100朵鮮花" 
android:textColor="#C0C0C0" 
android:textSize="10sp"/> 
<View 
android:layout_width="match_parent" 
android:layout_height="1dp" 
android:background="#CCCCCC" 
></View> 
</LinearLayout> 
<View 
android:layout_width="match_parent" 
android:layout_height="1dp" 
android:background="#CCCCCC" 
></View> 
<View 
android:layout_width="match_parent" 
android:layout_height="1dp" 
android:layout_marginTop="15dp" 
android:background="#CCCCCC" 
></View> 
<LinearLayout 
android:layout_width="match_parent" 
android:layout_height="0dp" 
android:layout_weight="1" 
android:background="@android:color/white" 
android:orientation="vertical"> 
<TextView 
android:layout_width="match_parent" 
android:layout_height="35dp" 
android:layout_marginLeft="15dp" 
android:gravity="center_vertical" 
android:text="緣分印象" 
android:textColor="#C0C0C0" 
android:textSize="14sp"/> 
<TextView 
android:layout_width="match_parent" 
android:layout_height="0dp" 
android:layout_weight="1" 
android:gravity="center" 
android:text="Ta還沒有緣分印象" 
android:textColor="#C0C0C0"/> 
</LinearLayout> 
</LinearLayout> 
<RelativeLayout 
android:id="@+id/mainactionbar" 
android:layout_width="match_parent" 
android:layout_height="55dp" 
> 
<ImageView 
android:id="@+id/userinfo_topbar" 
android:visibility="invisible" 
android:background="@color/colorTheme" 
android:layout_width="match_parent" 
android:layout_height="match_parent"/> 
<ImageButton 
android:id="@+id/userinfo_returnbtn" 
style="?android:attr/borderlessButtonStyle" 
android:layout_width="55dp" 
android:layout_height="55dp" 
android:padding="15dp" 
android:scaleType="fitCenter" 
android:src="@drawable/topbar_returnbtn"/> 
</RelativeLayout> 
</RelativeLayout>

該布局由內(nèi)而外嵌套了三層,其中上半部分我直接截了To圈的圖。

android:background="@drawable/top"

代碼實(shí)現(xiàn):

package com.whale.nangua.toquan; 
import android.animation.ObjectAnimator; 
import android.app.Activity; 
import android.content.Context; 
import android.os.Bundle; 
import android.support.v7.app.AppCompatActivity; 
import android.util.Log; 
import android.view.MotionEvent; 
import android.view.View; 
import android.view.ViewGroup; 
import android.widget.ImageView; 
import android.widget.LinearLayout; 
import android.widget.RelativeLayout; 
import android.widget.ScrollView; 
import android.widget.Toast; 
public class MainActivity extends Activity { 
LinearLayout myscrollLinearlayout; 
LinearLayout mainheadview; //頂部個(gè)人資料視圖 
RelativeLayout mainactionbar; //頂部菜單欄 
@Override 
protected void onCreate(Bundle savedInstanceState) { 
super.onCreate(savedInstanceState); 
setContentView(R.layout.userinfo_layout); 
initView(); 
} 
int Y; 
int position = 0; //拖動(dòng)Linearlayout的距離Y軸的距離 
int scrollviewdistancetotop = 0; //headView的高 
int menubarHeight = 0; 
int chufaHeight = 0; //需要觸發(fā)動(dòng)畫的高 
float scale; //像素密度 
int headViewPosition = 0; 
ImageView userinfo_topbar; 
static boolean flag = true; 
static boolean topmenuflag = true; 
private void initView() { 
userinfo_topbar = (ImageView) findViewById(R.id.userinfo_topbar); 
//獲得像素密度 
scale = this.getResources().getDisplayMetrics().density; 
mainheadview = (LinearLayout) findViewById(R.id.mainheadview); 
mainactionbar = (RelativeLayout) findViewById(R.id.mainactionbar); 
menubarHeight = (int) (55 * scale); 
chufaHeight = (int) (110 * scale); 
scrollviewdistancetotop = (int) ((260 )*scale); 
position = scrollviewdistancetotop; 
myscrollLinearlayout = (LinearLayout) findViewById(R.id.myscrollLinearlayout); 
myscrollLinearlayout.setY( scrollviewdistancetotop); //要減去Absolote布局距離頂部的高度 
myscrollLinearlayout.setOnClickListener(new View.OnClickListener() { 
@Override 
public void onClick(View v) { 
} 
}); 
myscrollLinearlayout.setOnTouchListener(new View.OnTouchListener() { 
@Override 
public boolean onTouch(View v, MotionEvent event) { 
switch (event.getAction()) { 
case MotionEvent.ACTION_DOWN: 
//按下的Y的位置 
Y = (int) event.getRawY(); 
break; 
case MotionEvent.ACTION_MOVE: 
int nowY = (int) myscrollLinearlayout.getY(); //拖動(dòng)界面的Y軸位置 
int tempY = (int) (event.getRawY() - Y); //手移動(dòng)的偏移量 
Y = (int) event.getRawY(); 
if ((nowY + tempY >= 0) && (nowY + tempY <= scrollviewdistancetotop)) { 
if ((nowY + tempY <= menubarHeight)&& (topmenuflag == true) ){ 
userinfo_topbar.setVisibility(View.VISIBLE); 
topmenuflag = false; 
} else if ((nowY + tempY > menubarHeight) && (topmenuflag == flag)) { 
userinfo_topbar.setVisibility(View.INVISIBLE); 
topmenuflag = true; 
} 
int temp = position += tempY; 
myscrollLinearlayout.setY(temp); 
int headviewtemp = headViewPosition += (tempY/5); 
mainheadview.setY(headviewtemp); 
} 
//頂部的動(dòng)畫效果 
if ((myscrollLinearlayout.getY() <= chufaHeight) && (flag == true)) { 
ObjectAnimator anim = ObjectAnimator.ofFloat(mainheadview, "alpha", 1, 0.0f); 
anim.setDuration(500); 
anim.start(); 
flag = false; 
} else if ((myscrollLinearlayout.getY() > chufaHeight + 40) && (flag == false)) { 
ObjectAnimator anim = ObjectAnimator.ofFloat(mainheadview, "alpha", 0.0f, 1f); 
anim.setDuration(500); 
anim.start(); 
flag = true; 
} 
break; 
} 
return false; 
} 
}); 
} 
}

代碼實(shí)現(xiàn)思路:

主要是對(duì)以下三個(gè)Layout的操作:

LinearLayout myscrollLinearlayout; //底部可拖動(dòng)的詳細(xì)界面
LinearLayout mainheadview; //頂部個(gè)人資料視圖
RelativeLayout mainactionbar; //頂部菜單欄

首先初始化各個(gè)布局部分的位置,然后主要是底部拖動(dòng)布局的動(dòng)態(tài)事件監(jiān)聽。

需要在這個(gè)監(jiān)聽方法中處理與另外兩個(gè)布局的交互,這一點(diǎn)比較麻煩,不過代碼里都有詳細(xì)的注釋。

然后這是我實(shí)現(xiàn)的效果圖:

可以看到跟To圈的效果幾乎一模一樣哦。

以上所述是小編給大家介紹的Android模仿To圈兒個(gè)人資料界面層疊淡入淡出顯示效果,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

  • Android Activity打開后被應(yīng)用快照遮住的問題

    Android Activity打開后被應(yīng)用快照遮住的問題

    這篇文章主要介紹了Android Activity打開后被應(yīng)用快照遮住的問題,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-01-01
  • Android中區(qū)別Drawable Bitmap Canvas Paint

    Android中區(qū)別Drawable Bitmap Canvas Paint

    本文主要介紹Android中Drawable Bitmap Canvas Paint 之間的區(qū)別,這里對(duì)這幾個(gè)概念做出詳細(xì)介紹,開發(fā)Android游戲的朋友可以參考下
    2016-07-07
  • Android 中SP與DP的區(qū)別實(shí)例詳解

    Android 中SP與DP的區(qū)別實(shí)例詳解

    這篇文章主要介紹了Android 中SP與DP的區(qū)別實(shí)例詳解的相關(guān)資料,需要的朋友可以參考下
    2016-10-10
  • Android實(shí)現(xiàn)果凍滑動(dòng)效果的控件

    Android實(shí)現(xiàn)果凍滑動(dòng)效果的控件

    這篇文章給大家主要介紹了利用Android如何實(shí)現(xiàn)果凍效果滑動(dòng)效果的控件,實(shí)現(xiàn)的效果類似于iOS有阻尼效果的滑動(dòng)控件,一般我們比較親切地稱之為果凍控件,常見的如微信里[我]的那個(gè)面板模塊,即使沒有再多的選項(xiàng),也不會(huì)很生硬的不允許用戶滑動(dòng)。下面來一起看看吧。
    2016-11-11
  • Flutter實(shí)現(xiàn)底部導(dǎo)航欄創(chuàng)建詳解

    Flutter實(shí)現(xiàn)底部導(dǎo)航欄創(chuàng)建詳解

    ConvexBottomBar是一個(gè)底部導(dǎo)航欄組件,用于展現(xiàn)凸起的TAB效果,支持多種內(nèi)置樣式與動(dòng)畫交互。本文將利用ConvexBottomBar創(chuàng)建漂亮的底部導(dǎo)航欄,感興趣的可以學(xué)習(xí)一下
    2022-01-01
  • Android切面編程知識(shí)點(diǎn)詳解

    Android切面編程知識(shí)點(diǎn)詳解

    這篇文章給大家整理了關(guān)于Android進(jìn)階資深開發(fā)必備技能-切面編程的相關(guān)知識(shí)點(diǎn)內(nèi)容,有興趣的朋友可以參考學(xué)習(xí)下。
    2018-07-07
  • Android 獲取未安裝的APK圖標(biāo)、版本號(hào)、包名等信息方法

    Android 獲取未安裝的APK圖標(biāo)、版本號(hào)、包名等信息方法

    下面小編就為大家分享一篇Android 獲取未安裝的APK圖標(biāo)、版本號(hào)、包名等信息方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。
    2018-01-01
  • Android compose氣泡升起和水滴下墜動(dòng)畫實(shí)現(xiàn)示例

    Android compose氣泡升起和水滴下墜動(dòng)畫實(shí)現(xiàn)示例

    這篇文章主要為大家介紹了Android compose氣泡升起和水滴下墜動(dòng)畫實(shí)現(xiàn)示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-01-01
  • Android防止按鈕重復(fù)點(diǎn)擊示例代碼

    Android防止按鈕重復(fù)點(diǎn)擊示例代碼

    本文介紹封裝的一個(gè)小的工具類庫(kù),按鈕點(diǎn)擊事件類庫(kù),該類庫(kù)可以防止按鈕重復(fù)點(diǎn)擊,可以判斷網(wǎng)絡(luò)狀態(tài),可以判斷用戶登錄態(tài),以及自定義驗(yàn)證條件等等,有興趣的可以了解一下
    2018-05-05
  • Android實(shí)現(xiàn)可復(fù)用的篩選頁面

    Android實(shí)現(xiàn)可復(fù)用的篩選頁面

    這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)可復(fù)用的篩選頁面,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-06-06

最新評(píng)論