Android-like double-click font amplification and sliding conflict, text display is incomplete, android-like font Amplification
Xml: Android: fillViewport = "true" must be used in scrollview. Otherwise, gravity = "ceter" is used in the nested layout of scrollview, which may cause incomplete text display and large white space at the bottom.
<? Xml version = "1.0" encoding = "UTF-8"?> <FrameLayout xmlns: android = "http://schemas.android.com/apk/res/android" android: layout_width = "match_parent" android: layout_height = "match_parent" android: background = "@ color/white"> <ScrollView android: layout_width = "match_parent" android: layout_height = "match_parent" android: fillViewport = "true"> <RelativeLayout android: layout_width = "match_parent" android: layout_height = "wrap_content"> <TextView android: id = "@ + id/TV _big_text" android: layout_width = "match_parent" android: layout_height = "wrap_content" android: layout_gravity = "center_vertical" android: layout_marginBottom = "15dp" android: layout_marginLeft = "15dp" android: layout_marginRight = "15dp" android: layout_marginTop = "15dp" android: gravity = "left | center" android: lineSpacingExtra = "5dp" android: minHeight = "500dp" android: text = "" android: textColor = "@ color/gray_3" android: textStyle = "bold"/> </RelativeLayout> </ScrollView> </FrameLayout>
Java: Double-click to zoom in
Package com. wangzhi. maMaHelp; import android. app. dialog; import android. content. context; import android. content. intent; import android. graphics. point; import android. OS. bundle; import android. text. method. scrollingMovementMethod; import android. util. typedValue; import android. view. gravity; import android. view. layoutInflater; import android. view. view; import android. view. view. onClickListener; import Android. view. windowManager; import android. widget. frameLayout; import android. widget. textView; /*** enlarge text **/public class BigTextActivity extends BaseActivity {/****** @ description start current act * @ author zhongwr * @ param content * enlarge text * @ param contentSize * enlarge font */public static void startBigTextAct (Context context, string content, int contentSize) {if (null! = Context &&! Tools. isEmpty (content) {Intent intent = new Intent (context, BigTextActivity. class); intent. putExtra ("content", content); intent. putExtra ("contentSize", contentSize); context. startActivity (intent) ;}} private String content; private TextView tvBigText; private int contetnSize; @ Override protected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); setContentView (R. layout. big_text_act); initViews (); initListener (); initData (savedInstanceState);}/*** initialize View */@ Override protected void initViews () {tvBigText = (TextView) findViewById (R. id. TV _big_text);} private void initData (Bundle savedInstanceState) {Intent intent = getIntent (); content = (String) intent. getStringExtra ("content"); contetnSize = (int) intent. getIntExtra ("contentSize", 16); tvBigText. setTextSize (TypedValue. COMPLEX_UNIT_SP, contetnSize); tvBigText. setMinHeight (mScreenHeight-Tools. dip2px (this, 15)-Tools. getStatusBarHeight (this); setEmojiTextView (tvBigText, content);} private void initListener () {tvBigText. setOnClickListener (this) ;}@ Override public void onClick (View v) {switch (v. getId () {case R. id. TV _big_text: finish (); break; default: break ;}}}
/***** @ Description get Status Bar Height * @ return Status Bar Height * @ update January 25, 2016 8:53:31 */public static int getStatusBarHeight (Context context) {if (statusBarHeight <= 0) {Rect frame = new Rect (); (Activity) context ). getWindow (). getDecorView (). getWindowVisibleDisplayFrame (frame); statusBarHeight = frame. top;} if (statusBarHeight <= 0) {try {Class <?> C = Class. forName ("com. android. internal. r$ dimen "); Object obj = c. newInstance (); Field field = c. getField ("status_bar_height"); int x = Integer. parseInt (field. get (obj ). toString (); statusBarHeight = context. getResources (). getDimensionPixelSize (x);} catch (Exception e1) {e1.printStackTrace () ;}} return statusBarHeight ;}
public static int dip2px(Context context, float dipValue) { return (int) (dipValue * density + 0.5f); }
Double-click
Import android. content. context; import android. view. view; import android. view. view. onClickListener;/*** double-click to enlarge the text listener */public class BigTextDoubleClickListener implements OnClickListener {private long lastClickTime; private Context mContext; /** double-click the font content */private String content; public BigTextDoubleClickListener (Context mContext, String content) {this. content = content; this. mContext = mContext;} @ Override public void onClick (View v) {// double-click if (System. currentTimeMillis ()-lastClickTime <= 1000) {// double-click "the interval between two clicks is less than one second. // jump to the enlarged BigTextActivity. startBigTextAct (mContext, content, 20);} lastClickTime = System. currentTimeMillis ();}}