當前位置: 首頁>>代碼示例>>Java>>正文


Java LinearLayout.getLayoutParams方法代碼示例

本文整理匯總了Java中android.widget.LinearLayout.getLayoutParams方法的典型用法代碼示例。如果您正苦於以下問題:Java LinearLayout.getLayoutParams方法的具體用法?Java LinearLayout.getLayoutParams怎麽用?Java LinearLayout.getLayoutParams使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.LinearLayout的用法示例。


在下文中一共展示了LinearLayout.getLayoutParams方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: showCenterToast

import android.widget.LinearLayout; //導入方法依賴的package包/類
public static void showCenterToast(Context context, String title, @DrawableRes int drawableId, int duration) {
    Toast toast = makeText(context.getApplicationContext(), title, duration);
    toast.setGravity(Gravity.CENTER, 0, 0);
    View view = LayoutInflater.from(context).inflate(R.layout.layout_center_toast, null);
    LinearLayout rlContent = (LinearLayout) view.findViewById(R.id.rl_content);
    TextView content = (TextView) view.findViewById(R.id.tv_content);
    ImageView alertIcon = (ImageView) view.findViewById(R.id.iv_icon);
    if (drawableId != 0) {
        alertIcon.setVisibility(View.VISIBLE);
        alertIcon.setImageResource(drawableId);
    } else {
        alertIcon.setVisibility(View.GONE);
    }
    if (!TextUtils.isEmpty(title)) {
        content.setText(title);
    }
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    int screenWidth = wm.getDefaultDisplay().getWidth();
    int width = (int) (screenWidth / 2f);
    FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) rlContent.getLayoutParams();
    lp.width = width;
    rlContent.setLayoutParams(lp);
    rlContent.requestLayout();
    toast.setView(view);
    toast.show();
}
 
開發者ID:Jusenr,項目名稱:androidtools,代碼行數:27,代碼來源:ToastUtils.java

示例2: showStart

import android.widget.LinearLayout; //導入方法依賴的package包/類
public static void showStart(Context context , int viewId) {
    if (context == null) {
        return;
    }
    final Toast toast = Toast.makeText(context, "", Toast.LENGTH_SHORT);
    View view ;
    if(viewId==0){
        view = LayoutInflater.from(context).inflate(R.layout.view_layout_toast_load,null,false);
    }else {
        view = LayoutInflater.from(context).inflate(viewId,null,false);
    }
    LinearLayout ll_toast = (LinearLayout) view.findViewById(R.id.toast);
    //布局文件中設置的寬高不頂用,需要重新設置;注意:不能設置最外層控件的寬高,會報空指針,可以設置第二層控件的寬高
    Activity activity = (Activity) context;
    WindowManager windowManager = activity.getWindowManager();
    Display display = windowManager.getDefaultDisplay();
    int screenWidth = display.getWidth();
    int screenHeight = display.getHeight();
    ll_toast.getLayoutParams().width = (int) (screenWidth*0.411);
    ll_toast.getLayoutParams().height = (int) (screenHeight*0.18);

    //設置吐司居中顯示
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.setView(view);
    toast.show();
}
 
開發者ID:yangchong211,項目名稱:YCDialog,代碼行數:27,代碼來源:ToastUtil.java

示例3: showDelete

import android.widget.LinearLayout; //導入方法依賴的package包/類
public static void showDelete(Context context, int viewId) {
    if (context == null) {
        return;
    }
    final Toast toast = Toast.makeText(context, "", Toast.LENGTH_SHORT);
    View view ;
    if(viewId==0){
        view = LayoutInflater.from(context).inflate(R.layout.view_layout_toast_delete,null,false);
    }else {
        view = LayoutInflater.from(context).inflate(viewId,null,false);
    }
    LinearLayout ll_toast = (LinearLayout) view.findViewById(R.id.toast);
    //布局文件中設置的寬高不頂用,需要重新設置;注意:不能設置最外層控件的寬高,會報空指針,可以設置第二層控件的寬高
    Activity activity = (Activity) context;
    WindowManager windowManager = activity.getWindowManager();
    Display display = windowManager.getDefaultDisplay();
    int screenWidth = display.getWidth();
    int screenHeight = display.getHeight();
    ll_toast.getLayoutParams().width = (int) (screenWidth*0.411);
    ll_toast.getLayoutParams().height = (int) (screenHeight*0.18);
    //設置吐司居中顯示
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.setView(view);
    toast.show();
}
 
開發者ID:yangchong211,項目名稱:YCDialog,代碼行數:26,代碼來源:ToastUtil.java

示例4: initView

import android.widget.LinearLayout; //導入方法依賴的package包/類
/**
 * 綁定搜索框xml視圖
 */
private void initView() {
    // 1. 綁定R.layout.search_layout作為搜索框的xml文件
    LayoutInflater.from(mContext).inflate(R.layout.search_layout,this);
    et_search = (EditText) findViewById(R.id.et_search);
    et_search.setTextSize(textSizeSearch);
    et_search.setTextColor(textColorSearch);
    et_search.setHint(textHintSearch);

    // 3. 搜索框背景顏色
    search_block = (LinearLayout) findViewById(R.id.search_linear);
    LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) search_block.getLayoutParams();
    params.height = searchBlockHeight;
    search_block.setBackgroundColor(searchBlockColor);
    search_block.setLayoutParams(params);

    // 4. 曆史搜索記錄 = ListView顯示
    listView = (SearchListView) findViewById(R.id.listView);

    // 5. 刪除曆史搜索記錄 按鈕
    tv_clear = (TextView) findViewById(R.id.tv_clear);
    tv_clear.setVisibility(INVISIBLE);

    // 6. 返回按鍵
    searchBack = (ImageView) findViewById(R.id.search_icon);
}
 
開發者ID:AndroidBoySC,項目名稱:Mybilibili,代碼行數:29,代碼來源:MySearchView.java

示例5: onCreate

import android.widget.LinearLayout; //導入方法依賴的package包/類
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setFullScreen();
    setContentView(R.layout.activity_camera);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitleTextColor(Color.WHITE);
    toolbar.setTitle(R.string.app_name);
    setSupportActionBar(toolbar);
    mCameraView = (CameraView) findViewById(R.id.camera_view);

    mRecordButton = (Button) findViewById(R.id.video);
    mRecordButton.setOnClickListener(this);
    mPictureButton = (Button) findViewById(R.id.picture);
    mPictureButton.setOnClickListener(this);

    int height = getResources().getDisplayMetrics().heightPixels / 4;
    LinearLayout controlLayout = (LinearLayout) findViewById(R.id.control);
    RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) controlLayout.getLayoutParams();
    layoutParams.height = height;
    controlLayout.setLayoutParams(layoutParams);
}
 
開發者ID:lytcom,項目名稱:CameraKitView,代碼行數:23,代碼來源:CameraActivity.java

示例6: initColorandLayout

import android.widget.LinearLayout; //導入方法依賴的package包/類
public void initColorandLayout(int color, int colorLight, int textColor, boolean inLandScape) {
    StreamerInfoName.setTextColor(textColor);
    StreamerInfoName.setBackgroundColor(colorLight);

    if(inLandScape){
        Log.v(LOG_TAG, "Is in landscape - Fragment");
        //StreamerInfoName.getLayoutParams().width = (int) (((getResources().getDisplayMetrics().widthPixels)/100) * StreamerInfoActivity.landscape_content_width - (context.getResources().getDimension(R.dimen.fragment_streamerInfo_cardElevation) * 2));
    } else {
        ContentLayout.setMaxCardElevation(0);
        ContentLayout.setCardElevation(0);
        int screenWidth = (getResources().getDisplayMetrics().widthPixels);
        LinearLayout llContainer = (LinearLayout) rootView.findViewById(R.id.fragment_streamerInfo_container_layout);

        int newWidth = (int)(screenWidth + getResources().getDimension(R.dimen.fragment_streamerInfo_cardElevation));
        llContainer.getLayoutParams().width = newWidth;

        float newTranslationX = (float)((newWidth - screenWidth) * -0.5);
        llContainer.setTranslationX(newTranslationX);
        llContainer.setGravity(Gravity.CENTER_HORIZONTAL);

    }
}
 
開發者ID:SebastianRask,項目名稱:Pocket-Plays-for-Twitch,代碼行數:23,代碼來源:StreamerInfoFragment.java

示例7: showLineraLayoutGroup

import android.widget.LinearLayout; //導入方法依賴的package包/類
/**
 * 顯示是否線性布局時的分組信息
 *
 * @param helper
 * @param isShow 是否顯示
 * @param time   時間戳
 * @describe
 */
private void showLineraLayoutGroup(boolean isShow, BaseViewHolder helper, long time) {
    // 有分組的列,marginTop為8dp,否則,為0dp
    LinearLayout ll = helper.getView(R.id.ll_note_list_linear);
    LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) ll.getLayoutParams();
    if (isShow) {
        helper.setVisible(R.id.tv_note_list_linear_month, true);
        setLinearGroupStyle(helper, time);

        params.setMargins(SizeUtils.dp2px(0), SizeUtils.dp2px(8), SizeUtils.dp2px(0), SizeUtils.dp2px(0));
        ll.setLayoutParams(params);

    } else {
        helper.setVisible(R.id.tv_note_list_linear_month, false);
        params.setMargins(SizeUtils.dp2px(0), SizeUtils.dp2px(0), SizeUtils.dp2px(0), SizeUtils.dp2px(0));
        ll.setLayoutParams(params);
    }
}
 
開發者ID:ifadai,項目名稱:SuperNote,代碼行數:26,代碼來源:RvNoteListAdapter.java

示例8: onCreate

import android.widget.LinearLayout; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.translucent_layout);
    tv=(TextView)this.findViewById(R.id.tv);
    int mode=getIntent().getIntExtra("mode",0);
    Log.d(TAG,"MODE:"+mode);
    //當係統版本為4.4或者4.4以上時可以使用沉浸式狀態欄
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        //透明狀態欄
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        //透明導航欄
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        if (mode == 0) {
             LinearLayout linear_bar=(LinearLayout)findViewById(R.id.linear_bar);
             linear_bar.setVisibility(View.VISIBLE);
             int statusHeight=getStatusBarHeight();
             android.widget.LinearLayout.LayoutParams params=(android.widget.LinearLayout.LayoutParams )linear_bar.getLayoutParams();
             params.height=statusHeight;
             linear_bar.setLayoutParams(params);
             tv.setText("係統方法沉浸式實現");
        } else if (mode == 1) {
            // create our manager instance after the content view is set
            SystemBarTintManager tintManager = new SystemBarTintManager(this);
            // 激活狀態欄
            tintManager.setStatusBarTintEnabled(true);
            // enable navigation bar tint 激活導航欄
            tintManager.setNavigationBarTintEnabled(true);
            //設置係統欄設置顏色
            //tintManager.setTintColor(R.color.red);
            //給狀態欄設置顏色
            tintManager.setStatusBarTintResource(R.color.middle_red);
            // 設置導航欄設置資源
            tintManager.setNavigationBarTintResource(R.color.color_nav);
            tv.setText("第三方庫沉浸式實現");
        }
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:39,代碼來源:TranslucentActivity.java

示例9: setUpViews

import android.widget.LinearLayout; //導入方法依賴的package包/類
@Override
protected void setUpViews(Context context, @Nullable AttributeSet attrs) {
	super.setUpViews(context, attrs);

	// get attributes
	TypedArray attributes = context.obtainStyledAttributes(attrs,
			R.styleable.LargeTextInputView);
	String buttonText =
			attributes.getString(R.styleable.LargeTextInputView_buttonText);
	int maxLines =
			attributes
					.getInteger(R.styleable.LargeTextInputView_maxLines, 0);
	boolean fillHeight = attributes
			.getBoolean(R.styleable.LargeTextInputView_fillHeight,
					false);
	attributes.recycle();

	if (buttonText != null) setButtonText(buttonText);
	if (maxLines > 0) ui.editText.setMaxLines(maxLines);
	if (fillHeight) {
		LinearLayout layout =
				(LinearLayout) findViewById(R.id.input_layout);
		LayoutParams params = (LayoutParams) layout.getLayoutParams();
		params.height = 0;
		params.weight = 1;
		layout.setLayoutParams(params);
		ViewGroup.LayoutParams editParams = ui.editText.getLayoutParams();
		editParams.height = MATCH_PARENT;
		ui.editText.setLayoutParams(editParams);
	}
}
 
開發者ID:rafjordao,項目名稱:Nird2,代碼行數:32,代碼來源:LargeTextInputView.java

示例10: onCreate

import android.widget.LinearLayout; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setFullScreen();
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitleTextColor(Color.WHITE);
    toolbar.setTitle(R.string.app_name);
    setSupportActionBar(toolbar);
    if (null == savedInstanceState) {
        mCamera2Fragment = Camera2Fragment.newInstance();
        getFragmentManager().beginTransaction()
            .replace(R.id.container, mCamera2Fragment)
            .commit();
    } else {
        mCamera2Fragment = (Camera2Fragment) getFragmentManager().findFragmentById(R.id.container);
    }

    mRecordButton = (Button) findViewById(R.id.video);
    mRecordButton.setOnClickListener(this);
    mPictureButton = (Button) findViewById(R.id.picture);
    mPictureButton.setOnClickListener(this);

    int height = getResources().getDisplayMetrics().heightPixels / 4;
    LinearLayout controlLayout = (LinearLayout) findViewById(R.id.control);
    RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) controlLayout.getLayoutParams();
    layoutParams.height = height;
    controlLayout.setLayoutParams(layoutParams);
}
 
開發者ID:lytcom,項目名稱:CameraKitView,代碼行數:30,代碼來源:MainActivity.java

示例11: resizeVideoContainer

import android.widget.LinearLayout; //導入方法依賴的package包/類
private void resizeVideoContainer(View v, int height) {
    LinearLayout videosContainer = (LinearLayout) v.findViewById(R.id.videos_container);
    FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) videosContainer.getLayoutParams();
    float density = context.getResources().getDisplayMetrics().density;
    params.topMargin = (int) (6 * density);
    params.height = height;
    videosContainer.setLayoutParams(params);
}
 
開發者ID:pawelpaszki,項目名稱:youtube_background_android,代碼行數:9,代碼來源:SearchFragment.java

示例12: createDialog

import android.widget.LinearLayout; //導入方法依賴的package包/類
public void createDialog() {
    setContentView(R.layout.dialog_bottom);
    show();
    Window window = getWindow();
    LinearLayout ll_content = (LinearLayout) window.findViewById(R.id.ll_content);
    window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT);
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) ll_content.getLayoutParams();
    layoutParams.gravity = Gravity.BOTTOM;
    ll_content.setLayoutParams(layoutParams);


}
 
開發者ID:pop1234o,項目名稱:BestPracticeApp,代碼行數:13,代碼來源:DialogActivity.java

示例13: Dock

import android.widget.LinearLayout; //導入方法依賴的package包/類
public Dock(Context context) {
	contextRef = new SoftReference<Context>(context);
	dockBar = (LinearLayout) ((Apps)context).findViewById(R.id.dock_bar);
	defaultHeight = dockBar.getLayoutParams().height;
	apps = new ArrayList<AppData>();
	buttons = new ArrayList<ImageView>();
	buttons.add((ImageView)((Apps)context).findViewById(R.id.button1));
	buttons.add((ImageView)((Apps)context).findViewById(R.id.button2));
	buttons.add((ImageView)((Apps)context).findViewById(R.id.button3));
	buttons.add((ImageView)((Apps)context).findViewById(R.id.button4));
	buttons.add((ImageView)((Apps)context).findViewById(R.id.button5));
	//update();
}
 
開發者ID:HenriDellal,項目名稱:emerald,代碼行數:14,代碼來源:Dock.java

示例14: initSearchView

import android.widget.LinearLayout; //導入方法依賴的package包/類
private void initSearchView() {
    SearchView searchView = mBinding.svSearch;
    //設置搜索框左邊距
    LinearLayout editFrame = (LinearLayout) findViewById(R.id.search_edit_frame);
    LinearLayout.LayoutParams editP = (LayoutParams) editFrame.getLayoutParams();
    editP.leftMargin = 0;
    editP.rightMargin = 0;
    ImageView imageView = (ImageView) findViewById(R.id.search_mag_icon);
    imageView.setAdjustViewBounds(true);
    imageView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    LinearLayout.LayoutParams lp3 = (LayoutParams) imageView.getLayoutParams();
    lp3.gravity = Gravity.CENTER_VERTICAL;
    lp3.leftMargin = (int) (DensityUtil.dip2px(8f) * DensityUtil.getBaseScale(getContext()));
    lp3.rightMargin = (int) (DensityUtil.dip2px(-2f) * DensityUtil.getBaseScale(getContext()));

    View view = searchView.findViewById(R.id.search_plate);
    view.setBackgroundColor(getResources().getColor(R.color.colorTransparent));
    EditText editText = (EditText) searchView.findViewById(R.id.search_src_text);
    editText.setBackgroundColor(Color.TRANSPARENT);
    editText.setTextSize(11.5f);
    editText.setTextColor(getResources().getColor(R.color.colorText));
    editText.setHintTextColor(getResources().getColor(R.color.colorHint));
    try {
        Field fCursorDrawableRes = TextView.class.getDeclaredField("mCursorDrawableRes");
        fCursorDrawableRes.setAccessible(true);
        int mCursorDrawableRes = fCursorDrawableRes.getInt(editText);
        Field fEditor = TextView.class.getDeclaredField("mEditor");
        fEditor.setAccessible(true);
        Object editor = fEditor.get(editText);
        Class<?> clazz = editor.getClass();
        Field fCursorDrawable = clazz.getDeclaredField("mCursorDrawable");
        fCursorDrawable.setAccessible(true);
        if (mCursorDrawableRes <= 0) return;
        Drawable cursorDrawable = ContextCompat.getDrawable(searchView.getContext(), mCursorDrawableRes);
        if (cursorDrawable == null) return;
        Drawable tintDrawable = DrawableCompat.wrap(cursorDrawable);
        DrawableCompat.setTintList(tintDrawable, ColorStateList.valueOf(ContextCompat.getColor(getContext(), R.color.bg_search)));
        Drawable[] drawables = new Drawable[]{tintDrawable, tintDrawable};
        fCursorDrawable.set(editor, drawables);
    } catch (Throwable t) {
        t.printStackTrace();
    }
}
 
開發者ID:xieyangxuejun,項目名稱:SearchLayout,代碼行數:44,代碼來源:FlowSearchLayout.java

示例15: initUIandEvent

import android.widget.LinearLayout; //導入方法依賴的package包/類
@Override
protected void initUIandEvent() {
    event().addEventHandler(this);

    Intent i = getIntent();

    String channelName = i.getStringExtra(ConstantApp.ACTION_KEY_CHANNEL_NAME);

    final String encryptionKey = getIntent().getStringExtra(ConstantApp.ACTION_KEY_ENCRYPTION_KEY);

    final String encryptionMode = getIntent().getStringExtra(ConstantApp.ACTION_KEY_ENCRYPTION_MODE);

    doConfigEngine(encryptionKey, encryptionMode);

    mGridVideoViewContainer = (GridVideoViewContainer) findViewById(R.id.grid_video_view_container);
    mGridVideoViewContainer.setItemEventHandler(new VideoViewEventListener() {
        @Override
        public void onItemDoubleClick(View v, Object item) {
            log.debug("onItemDoubleClick " + v + " " + item + " " + mLayoutType);

            if (mUidsList.size() < 2) {
                return;
            }

            UserStatusData user = (UserStatusData) item;
            int uid = (user.mUid == 0) ? config().mUid : user.mUid;

            if (mLayoutType == LAYOUT_TYPE_DEFAULT && mUidsList.size() != 1) {
                switchToSmallVideoView(uid);
            } else {
                switchToDefaultVideoView();
            }
        }
    });

    SurfaceView surfaceV = RtcEngine.CreateRendererView(getApplicationContext());
    rtcEngine().setupLocalVideo(new VideoCanvas(surfaceV, VideoCanvas.RENDER_MODE_HIDDEN, 0));
    surfaceV.setZOrderOnTop(false);
    surfaceV.setZOrderMediaOverlay(false);

    mUidsList.put(0, surfaceV); // get first surface view

    mGridVideoViewContainer.initViewContainer(getApplicationContext(), 0, mUidsList); // first is now full view
    worker().preview(true, surfaceV, 0);
    config().mUid = AGApplication.uid;
    String channelKey = AGApplication.channelKey;
    worker().joinChannel(channelName, config().mUid,channelKey);

    TextView textChannelName = (TextView) findViewById(R.id.channel_name);
    textChannelName.setText(channelName);

    optional();

    LinearLayout bottomContainer = (LinearLayout) findViewById(R.id.bottom_container);
    FrameLayout.MarginLayoutParams fmp = (FrameLayout.MarginLayoutParams) bottomContainer.getLayoutParams();
    fmp.bottomMargin = virtualKeyHeight() + 16;

    initMessageList();
}
 
開發者ID:huangjingqiang,項目名稱:SWDemo,代碼行數:60,代碼來源:ChatActivity.java


注:本文中的android.widget.LinearLayout.getLayoutParams方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。