本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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("第三方库沉浸式实现");
}
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
示例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();
}
}
示例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();
}