Skip to content

Instantly share code, notes, and snippets.

@LuizGadao
Last active October 6, 2015 03:45
Show Gist options
  • Save LuizGadao/fcebe904f54a30c8376b to your computer and use it in GitHub Desktop.
Save LuizGadao/fcebe904f54a30c8376b to your computer and use it in GitHub Desktop.
textview-mask
package com.luizgadao.navigationdrawer;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
/**
* A simple {@link Fragment} subclass.
*/
public class BlankFragment extends Fragment {
public BlankFragment() {
// Required empty public constructor
}
@Override
public View onCreateView( LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState ) {
// Inflate the layout for this fragment
return inflater.inflate( R.layout.fragment_blank, container, false );
}
@Override
public void onViewCreated( View view, Bundle savedInstanceState ) {
super.onViewCreated( view, savedInstanceState );
Button bt = ( Button ) view.findViewById( R.id.bt );
bt.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick( View view ) {
getFragmentManager()
.beginTransaction()
.add( R.id.content_fragment, new BlankFragment() )
.addToBackStack( null )
.setTransition( FragmentTransaction.TRANSIT_FRAGMENT_OPEN )
.commit();
}
} );
View content1 = view.findViewById( R.id.content1 );
final int width = content1.getLayoutParams().width;
final LinearLayout content2 = ( LinearLayout ) view.findViewById( R.id.content2 );
Thread thread = new Thread( new Runnable() {
@Override
public void run() {
try {
int i = 0;
int step = 20;
int w = 0;
while ( w < width ) {
Thread.sleep( 400 );
final ViewGroup.LayoutParams layoutParams = content2.getLayoutParams();
w = i * step;
layoutParams.width = w;
Log.i( "Thread", "teste: " + w );
content2.post( new Runnable() {
@Override
public void run() {
content2.setLayoutParams( layoutParams );
}
} );
i++;
}
}
catch ( Exception e ) {
e.printStackTrace();
}
}
} );
thread.start();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment