目前分類:畫面 (9)

瀏覽方式: 標題列表 簡短摘要

1.啟用databinding:

gradle

JBLin 發表在 痞客邦 留言(0) 人氣()

1.gradle依賴:

implementation 'com.android.support:recyclerview-v7:28.0.0'

2.adapter

JBLin 發表在 痞客邦 留言(0) 人氣()

Spannable span = new SpannableString(Text);
int start = 0;
int end = 0;
while (start != -1 ) {//title setting textSpan
    start = content4.getText().toString().indexOf("\n \n", end);//區間開頭
    end = content4.getText().toString().indexOf("\n", content4.getText().toString().indexOf("\n \n", end) + 4);//區間結尾
    if(end > start && start >= 0)//有取得正確的開頭和結尾索引則新增特效
        span.setSpan(new AbsoluteSizeSpan(28), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);//字體放大為28
}
textview.setText(span);

JBLin 發表在 痞客邦 留言(0) 人氣()

放大動畫
* @param startScaleX x原本比例
* @param startScaleY y原本比例
* @param endScaleX x放大比例
* @param endScaleY y放大比例
* @param positionX 轉的位置 getPivotX()為中心 0為左邊 getX()為右邊
* @param positionY 轉的位置 getPivotY()為中心 0為上面 getY()為下面
Animation animation = new ScaleAnimation(startScaleX, endScaleX,startScaleY,endScaleY,positionX,positionY);

平移動畫
* @param startX 開始的X(以左上角為0)
* @param startY 開始的Y(以左上角為0)
* @param endX 往右移動多少X
* @param endY 往下移動多少Y
Animation animation = new TranslateAnimation(startX, endX,startY,endY);
轉圈動畫
* @param startAngle 開始轉的角度
* @param endAngle 結束停的角度
* @param Xcenter 轉的中心點X
* @param Ycenter 轉的中心點Y
Animation animation = new RotateAnimation(startAngle, endAngle, Animation.RELATIVE_TO_SELF, Xcenter, Animation.RELATIVE_TO_SELF, Ycenter);
--------------------------------------------------------------------------------------------------------------------------------------
animation.setInterpolator(new LinearInterpolator());//順順的動
animation.setDuration(cycleTime);//轉動時間ms
animation.setRepeatCount(Animation.INFINITE);//設定動畫執行次數(INFINITE為重複)
 

JBLin 發表在 痞客邦 留言(0) 人氣()

取得dp TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,(float) 長度,getResources().getDisplayMetrics())
取得sp  TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP,(float) 長度,getResources().getDisplayMetrics())
取得pt TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PT,(float) 長度,getResources().getDisplayMetrics())
取得px TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX,(float) 長度,getResources().getDisplayMetrics())
取得mm TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_MM,(float) 長度,getResources().getDisplayMetrics())

JBLin 發表在 痞客邦 留言(0) 人氣()

layout_gravity 物件相對於父物件的位置
gravity 物件內資料的位置

JBLin 發表在 痞客邦 留言(0) 人氣()

WindowManager windowManager = null;//系統層
WindowManager.LayoutParams params = null;//排版

params = new WindowManager.LayoutParams(//排版設定
        WindowManager.LayoutParams.FLAG_LAYOUT_IN_OVERSCAN,
        WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
        PixelFormat.TRANSLUCENT);
windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);

 

params.width = WindowManager.LayoutParams.MATCH_PARENT;//物件layout的寬
params.height = 60;
params.gravity = Gravity.TOP;//物件layout的位子
titleBG = new ImageView(this);//物件init
titleBG.setBackgroundColor(Color.parseColor("#501f2424"));//物件設定圖片及顏色
windowManager.addView(titleBG, params);//將物件及排版加入windowManager

文章標籤

JBLin 發表在 痞客邦 留言(0) 人氣()

<application 
android:theme="@style/translucent">
</application>

//背景透明

<style name="translucent" parent="@android:style/Theme.Translucent">
    <item name="android:windowNoTitle">true</item>
</style>

//背景設定一張圖片

文章標籤

JBLin 發表在 痞客邦 留言(0) 人氣()

.xml
<TextView android:scrollbars = "vertical"/>

程式碼:

private int pageIndex = 0 ;
private TextView text;
text = (TextView) findViewById(R.id.text);
text.setMovementMethod(new ScrollingMovementMethod(){
    @Override
    public boolean onKeyDown(TextView widget, Spannable text, int keyCode, KeyEvent event) {
        if(keyCode == KeyEvent.KEYCODE_DPAD_DOWN){//
            nextText();
            return false;
        }else if(keyCode == KeyEvent.KEYCODE_DPAD_UP){
            preText();
            return false;
        }
        return super.onKeyDown(widget, text, keyCode, event);
    }
});
private void nextText(){
    if(pageIndex == 0){
        image.setVisibility(View.GONE);
        text.scrollTo(0, text.getLayout().getLineTop(行數* (pageIndex+1)));
        pageIndex++;
    }else if(text.canScrollVertically(1)){
        text.scrollTo(0, text.getLayout().getLineTop(* (pageIndex+1)));
        pageIndex++;
    }
}

 

文章標籤

JBLin 發表在 痞客邦 留言(0) 人氣()