Java Code Examples for android.widget.LinearLayout.measure()

The following are Jave code examples for showing how to use measure() of the android.widget.LinearLayout class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: GitHub   File: PullToRefreshListView.java   View Source Code Vote up 6 votes
private void init(Context context) {
	mFlipAnimation = new RotateAnimation(0, -180,
			RotateAnimation.RELATIVE_TO_SELF, 0.5f,
			RotateAnimation.RELATIVE_TO_SELF, 0.5f);
	mFlipAnimation.setInterpolator(new LinearInterpolator());
	mFlipAnimation.setDuration(250);
	mFlipAnimation.setFillAfter(true);
	mReverseFlipAnimation = new RotateAnimation(-180, 0,
			RotateAnimation.RELATIVE_TO_SELF, 0.5f,
			RotateAnimation.RELATIVE_TO_SELF, 0.5f);
	mReverseFlipAnimation.setInterpolator(new LinearInterpolator());
	mReverseFlipAnimation.setDuration(250);
	mReverseFlipAnimation.setFillAfter(true);

	mRefreshView = (LinearLayout) View.inflate(context, R.layout.pull_to_refresh_header, null);
	mRefreshViewText = (TextView) mRefreshView.findViewById(R.id.pull_to_refresh_text);
	mRefreshViewImage = (ImageView) mRefreshView.findViewById(R.id.pull_to_refresh_image);
	mRefreshViewProgress = (ProgressBar) mRefreshView.findViewById(R.id.pull_to_refresh_progress);
	mRefreshViewLastUpdated = (TextView) mRefreshView.findViewById(R.id.pull_to_refresh_updated_at);

	mRefreshState = PULL_TO_REFRESH;
	mRefreshViewImage.setMinimumHeight(50); //设置下拉最小的高度为50
	
	setFadingEdgeLength(0);
	setHeaderDividersEnabled(false);

	//把refreshview加入到listview的头部
	addHeaderView(mRefreshView);
	super.setOnScrollListener(this);
	mRefreshView.setOnClickListener(this);

	mRefreshView.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
	mRefreshViewHeight = mRefreshView.getMeasuredHeight();
	mRefreshOriginalTopPadding = -mRefreshViewHeight;
	
	resetHeaderPadding();
}
 
Example 2
Project: Taxi-App-Android-XML   File: MyTrip.java   View Source Code Vote up 6 votes
public Bitmap getBitmapFromView(String title, int dotBg) {

        LinearLayout llmarker = (LinearLayout) findViewById(R.id.ll_marker);
        TextView markerImageView = (TextView) findViewById(R.id.tv_title);
        markerImageView.setText(title);
        View dot = (View) findViewById(R.id.dot_marker);
        dot.setBackgroundResource(dotBg);

        llmarker.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
        Bitmap bitmap = Bitmap.createBitmap(llmarker.getMeasuredWidth(), llmarker.getMeasuredHeight(),
                Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        llmarker.layout(0, 0, llmarker.getMeasuredWidth(), llmarker.getMeasuredHeight());
        llmarker.draw(canvas);
        return bitmap;
    }
 
Example 3
Project: Taxi-App-Android-XML   File: Home.java   View Source Code Vote up 6 votes
public Bitmap getBitmapFromView(String title, int dotBg) {

        LinearLayout llmarker = (LinearLayout) findViewById(R.id.ll_marker);
        TextView markerImageView = (TextView) findViewById(R.id.tv_title);
        markerImageView.setText(title);
        View dot = (View) findViewById(R.id.dot_marker);
        dot.setBackgroundResource(dotBg);

        llmarker.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
        Bitmap bitmap = Bitmap.createBitmap(llmarker.getMeasuredWidth(), llmarker.getMeasuredHeight(),
                Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        llmarker.layout(0, 0, llmarker.getMeasuredWidth(), llmarker.getMeasuredHeight());
        llmarker.draw(canvas);
        return bitmap;
    }
 
Example 4
Project: Slide-RSS   File: MainActivity.java   View Source Code Vote up 5 votes
private void expand(LinearLayout v) {
    //set Visible
    v.setVisibility(View.VISIBLE);

    final int widthSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    final int heightSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    v.measure(widthSpec, heightSpec);

    ValueAnimator mAnimator = slideAnimator(0, v.getMeasuredHeight(), v);
    mAnimator.start();
}
 
Example 5
Project: Mybilibili   File: MainActivity.java   View Source Code Vote up 5 votes
/**
     * 点击头像后的操作
     * @param view
     */
    public void Login(View view){
        //通过存储在本地的用户信息及登录状态判断所要打开的页面
//        String name = mPreferences.getString("userName", "0");
//        String passWord = mPreferences.getString("passWord", "0");
        //这块必须要再取一次,否则由未登录转为登录时isLogin值还是false
        isLogin = mPreferences.getBoolean("isLogin", false);
       if(isLogin){
            //打个吐司测试一下,实际上要做选取图片或拍照的操作
            //Toast.makeText(MainActivity.this,"你已经登陆了",Toast.LENGTH_SHORT).show();
            //textViewLogin.setText("已登录");这句写在这里是有问题的,应该写在onCreate方法中
           mCameraDialog = new Dialog(MainActivity.this,R.style.my_dialog);
           LinearLayout root = (LinearLayout) LayoutInflater.from(MainActivity.this).inflate(R.layout.camera_control,null);
           root.findViewById(R.id.btn_camera).setOnClickListener(btnListener);
           root.findViewById(R.id.btn_photo).setOnClickListener(btnListener);
           root.findViewById(R.id.btn_cancel).setOnClickListener(btnListener);
           //将dialog布局通过setcontentview填充
           mCameraDialog.setContentView(root);
           Window dialogWindow = mCameraDialog.getWindow();
           dialogWindow.setGravity(Gravity.BOTTOM);
           //有个滑出的动画,对高度进行设置,不让他全屏
           //dialogWindow.setWindowAnimations(R.style.dialogstyle);
           WindowManager.LayoutParams lp = dialogWindow.getAttributes();//获取对话框当前的参数值
           lp.x = 0; // 新位置X坐标
           lp.y = -20; // 新位置Y坐标
           lp.width =(int)getResources().getDisplayMetrics().widthPixels;// 宽度  
//      lp.height = WindowManager.LayoutParams.WRAP_CONTENT;//高度
//     lp.alpha = 9f; //透明度
           root.measure(0,0);
           lp.height = root.getMeasuredHeight();
           lp.alpha = 9f; // 透明度  
           dialogWindow.setAttributes(lp);
           mCameraDialog.show();
        }else {
           Intent intent = new Intent(MainActivity.this,LoginActivity.class);
           startActivity(intent);
       }
    }