日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

android多媒体编程题库,android 仿猿题库答题UI

發布時間:2024/9/3 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android多媒体编程题库,android 仿猿题库答题UI 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

需要做類似猿題庫答題板效果,網上沒有找到Android的,就自己寫一個,浮層上滑底層UI跟著改變的UI

public class DragLinearLayoutextends LinearLayout {

private int screenWidth;

private int screenHeight;

int lastX, lastY;

// 滑動監聽

public TouchListenertouchListener;

public DragLinearLayout(Context context) {

super(context);

init();

}

public DragLinearLayout(Context context, AttributeSet attrs) {

super(context, attrs);

init();

}

public void setTouchListener(TouchListener touchListener) {

this.touchListener = touchListener;

}

public void init() {

DisplayMetrics dm = getResources().getDisplayMetrics();

screenWidth = dm.widthPixels;

screenHeight = dm.heightPixels;

}

@Override

protected void onLayout(boolean changed, int l, int t, int r, int b) {

// TODO Auto-generated method stub

super.onLayout(changed, l, t, r, b);

}

/**

*

* @param groupViewHeight 父容器高度-拖拽按鈕高度

* @param v

* @param event

*/

public void slideView(int groupViewHeight,View v, MotionEvent event){

int action = event.getAction();

switch (action) {

case MotionEvent.ACTION_DOWN:

lastX = (int) event.getRawX();

lastY = (int) event.getRawY();

break;

case MotionEvent.ACTION_MOVE:

int dx = (int) event.getRawX() -lastX;

int dy = (int) event.getRawY() -lastY;

int left = DragLinearLayout.this.getLeft() + dx;

int top = DragLinearLayout.this.getTop() + dy;

int right = DragLinearLayout.this.getRight() + dx;

int bottom = DragLinearLayout.this.getBottom() + dy;

if (left <0) {

left =0;

right = left + DragLinearLayout.this.getWidth();

}

if (right >screenWidth) {

right =screenWidth;

left = right - DragLinearLayout.this.getWidth();

}

if (top <0) {

top =0;

bottom = top + DragLinearLayout.this.getHeight();

}

if (top > groupViewHeight) {

RelativeLayout.LayoutParams rl = (RelativeLayout.LayoutParams) getLayoutParams();

top = groupViewHeight;

rl.topMargin = top;

setLayoutParams(rl);

callBackMessage(left, top, right, bottom);

return ;

}else {

callBackMessage(left, top, right, bottom);

}

RelativeLayout.LayoutParams rl = (RelativeLayout.LayoutParams) getLayoutParams();

rl.topMargin = top;

setLayoutParams(rl);

lastX = (int) event.getRawX();

lastY = (int) event.getRawY();

break;

}

}

private void callBackMessage(int left,int top,int right,int bottom){

if(touchListener!=null){

touchListener.backTouchState(left, top, right, bottom);

}

}

/**

* Touch監聽接口

*/

public interface TouchListener {public void backTouchState(int left, int top, int right, int bottom);}

}

布局

MainActivity

主要方法

/**

* 按鈕的觸摸事件

*/

btn_drag.setOnTouchListener(new View.OnTouchListener() {

@Override

public boolean onTouch(View view, MotionEvent motionEvent) {

//觸摸按鈕的高度

int height_drag =btn_drag.getHeight();

//父容器的高度

int height =rel.getHeight();

int i = height - height_drag;

//滑動浮層

sbrl.slideView(i,view,motionEvent);

return false;

}

});

/**

* 被覆蓋層隨隨著浮層的滑動改變大小

*/

sbrl.setTouchListener(new DragLinearLayout.TouchListener() {

@Override

public void backTouchState(int left, int top, int right, int bottom) {

int bottom1 =sbrl.getBottom();

int height_drag? =btn_drag.getHeight();

int height =rel.getHeight();

RelativeLayout.LayoutParams rl = (RelativeLayout.LayoutParams)neds.getLayoutParams();

rl.bottomMargin =height-top-height_drag;

neds.setLayoutParams(rl);

Log.e("ice","------left---------" + left +"--top-" + top

+"----right--" + right +"---bottom-" + bottom+

"-------bottom1 = "+bottom1+" i "+i);

}

});

//第一次寫,希望能幫到大家,

總結

以上是生活随笔為你收集整理的android多媒体编程题库,android 仿猿题库答题UI的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。