Search in sources :

Example 1 with LayoutParams

use of android.widget.LinearLayout.LayoutParams in project android-app by eoecn.

the class UserCollectFragment method CreateTextView.

private TextView CreateTextView(final int i, String name) {
    // TODO Auto-generated method stub
    TextView tv = new TextView(mContext);
    int width = wm.getDefaultDisplay().getWidth() / 3;
    LayoutParams layout = new LayoutParams(width, LayoutParams.MATCH_PARENT);
    tv.setLayoutParams(layout);
    if (i == 0) {
        tv.setBackgroundResource(R.drawable.dis_usercollect_left);
        mLinearLayout.setTag(tv);
    }
    tv.setGravity(Gravity.CENTER);
    tv.setTextColor(Color.BLACK);
    tv.setText(name);
    tv.setClickable(true);
    tv.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            mUserFragment.setListContent(mUserResponse.getFavorite().get(i));
            if (mLinearLayout.getTag() != null) {
                ((View) mLinearLayout.getTag()).setBackgroundColor(Color.TRANSPARENT);
            }
            mLinearLayout.setTag(v);
            if (i == 0) {
                v.setBackgroundResource(R.drawable.dis_usercollect_left);
            } else if (i == mUserResponse.getFavorite().size() - 1) {
                v.setBackgroundResource(R.drawable.dis_usercollect_right);
            }
        }
    });
    return tv;
}
Also used : LayoutParams(android.widget.LinearLayout.LayoutParams) TextView(android.widget.TextView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Example 2 with LayoutParams

use of android.widget.LinearLayout.LayoutParams in project android_frameworks_base by ParanoidAndroid.

the class PowerTestActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.v(LOGTAG, "onCreate, inst=" + Integer.toHexString(hashCode()));
    LinearLayout contentView = new LinearLayout(this);
    contentView.setOrientation(LinearLayout.VERTICAL);
    setContentView(contentView);
    setTitle("Idle");
    webView = new WebView(this);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
    webView.getSettings().setLayoutAlgorithm(LayoutAlgorithm.NORMAL);
    webViewClient = new SimpleWebViewClient();
    chromeClient = new SimpleChromeClient();
    webView.setWebViewClient(webViewClient);
    webView.setWebChromeClient(chromeClient);
    contentView.addView(webView, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 0.0f));
    handler = new Handler() {

        @Override
        public void handleMessage(Message msg) {
            switch(msg.what) {
                case MSG_TIMEOUT:
                    handleTimeout();
                    return;
                case MSG_NAVIGATE:
                    manualDelay = msg.arg2;
                    navigate(msg.getData().getString(MSG_NAV_URL), msg.arg1);
                    logTime = msg.getData().getBoolean(MSG_NAV_LOGTIME);
                    return;
            }
        }
    };
    pageDoneLock = new Object();
}
Also used : LayoutParams(android.widget.LinearLayout.LayoutParams) Message(android.os.Message) Handler(android.os.Handler) WebView(android.webkit.WebView) LinearLayout(android.widget.LinearLayout)

Example 3 with LayoutParams

use of android.widget.LinearLayout.LayoutParams in project android_frameworks_base by ParanoidAndroid.

the class ReliabilityTestActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.v(LOGTAG, "onCreate, inst=" + Integer.toHexString(hashCode()));
    LinearLayout contentView = new LinearLayout(this);
    contentView.setOrientation(LinearLayout.VERTICAL);
    setContentView(contentView);
    setTitle("Idle");
    webView = new WebView(this);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
    webView.getSettings().setLayoutAlgorithm(LayoutAlgorithm.NORMAL);
    webViewClient = new SimpleWebViewClient();
    chromeClient = new SimpleChromeClient();
    webView.setWebViewClient(webViewClient);
    webView.setWebChromeClient(chromeClient);
    contentView.addView(webView, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 0.0f));
    handler = new Handler() {

        @Override
        public void handleMessage(Message msg) {
            switch(msg.what) {
                case MSG_TIMEOUT:
                    handleTimeout();
                    return;
                case MSG_NAVIGATE:
                    manualDelay = msg.arg2;
                    navigate(msg.getData().getString(MSG_NAV_URL), msg.arg1);
                    logTime = msg.getData().getBoolean(MSG_NAV_LOGTIME);
                    return;
            }
        }
    };
    pageDoneLock = new Object();
}
Also used : LayoutParams(android.widget.LinearLayout.LayoutParams) Message(android.os.Message) SslErrorHandler(android.webkit.SslErrorHandler) Handler(android.os.Handler) HttpAuthHandler(android.webkit.HttpAuthHandler) WebView(android.webkit.WebView) LinearLayout(android.widget.LinearLayout)

Example 4 with LayoutParams

use of android.widget.LinearLayout.LayoutParams in project android_frameworks_base by ParanoidAndroid.

the class LinearLayoutTest method create.

public ViewGroup create(Context context) {
    LinearLayout container = new LinearLayout(context);
    container.setOrientation(LinearLayout.VERTICAL);
    for (int i = 0; i < VERTICAL_ALIGNMENTS.length; i++) {
        int va = VERTICAL_ALIGNMENTS[i];
        for (int j = 0; j < HORIZONTAL_ALIGNMENTS.length; j++) {
            int ha = HORIZONTAL_ALIGNMENTS[j];
            LayoutParams lp = new LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
            lp.gravity = va | ha;
            View v = create(context, VERTICAL_NAMES[i] + "-" + HORIZONTAL_NAMES[j], 20);
            container.addView(v, lp);
        }
    }
    return container;
}
Also used : LayoutParams(android.widget.LinearLayout.LayoutParams) View(android.view.View) LinearLayout(android.widget.LinearLayout)

Example 5 with LayoutParams

use of android.widget.LinearLayout.LayoutParams in project Anki-Android by Ramblurr.

the class BasicImageFieldController method createUI.

@Override
public void createUI(LinearLayout layout) {
    mImagePreview = new ImageView(mActivity);
    DisplayMetrics metrics = getDisplayMetrics();
    int height = metrics.heightPixels;
    int width = metrics.widthPixels;
    LinearLayout.LayoutParams p = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
    setPreviewImage(mField.getImagePath(), getMaxImageSize());
    mImagePreview.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    mImagePreview.setAdjustViewBounds(true);
    mImagePreview.setMaxHeight((int) Math.round(height * 0.4));
    mImagePreview.setMaxWidth((int) Math.round(width * 0.6));
    mBtnGallery = new Button(mActivity);
    mBtnGallery.setText(gtxt(R.string.multimedia_editor_image_field_editing_galery));
    mBtnGallery.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
            mActivity.startActivityForResult(i, ACTIVITY_SELECT_IMAGE);
        }
    });
    mBtnCamera = new Button(mActivity);
    mBtnCamera.setText(gtxt(R.string.multimedia_editor_image_field_editing_photo));
    mBtnCamera.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            File image;
            try {
                image = File.createTempFile("ankidroid_img", ".jpg");
                mTempCameraImagePath = image.getPath();
                Uri uriSavedImage = Uri.fromFile(image);
                cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedImage);
                mActivity.startActivityForResult(cameraIntent, ACTIVITY_TAKE_PICTURE);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    });
    layout.addView(mImagePreview, LinearLayout.LayoutParams.FILL_PARENT, p);
    layout.addView(mBtnGallery, LinearLayout.LayoutParams.FILL_PARENT);
    layout.addView(mBtnCamera, LinearLayout.LayoutParams.FILL_PARENT);
}
Also used : LayoutParams(android.widget.LinearLayout.LayoutParams) Intent(android.content.Intent) IOException(java.io.IOException) DisplayMetrics(android.util.DisplayMetrics) ImageView(android.widget.ImageView) View(android.view.View) Uri(android.net.Uri) LayoutParams(android.widget.LinearLayout.LayoutParams) Button(android.widget.Button) ImageView(android.widget.ImageView) File(java.io.File) LinearLayout(android.widget.LinearLayout)

Aggregations

LayoutParams (android.widget.LinearLayout.LayoutParams)78 LinearLayout (android.widget.LinearLayout)44 View (android.view.View)36 TextView (android.widget.TextView)24 ImageView (android.widget.ImageView)17 Button (android.widget.Button)16 ProgressBar (android.widget.ProgressBar)9 Message (android.os.Message)8 OnClickListener (android.view.View.OnClickListener)8 ScrollView (android.widget.ScrollView)7 Handler (android.os.Handler)6 ViewGroup (android.view.ViewGroup)6 WebView (android.webkit.WebView)6 HorizontalScrollView (android.widget.HorizontalScrollView)5 ChangeBounds (android.transition.ChangeBounds)4 Crossfade (android.transition.Crossfade)4 Scene (android.transition.Scene)4 TransitionSet (android.transition.TransitionSet)4 SurfaceView (android.view.SurfaceView)4 TextureView (android.view.TextureView)4