Android-like WeChat double-click to enlarge the font and sliding conflict, text display is incomplete, android-like font Amplification

Source: Internet
Author: User

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 ();}}

  

  

  

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.