本文整理汇总了Java中android.widget.LinearLayout.setOrientation方法的典型用法代码示例。如果您正苦于以下问题:Java LinearLayout.setOrientation方法的具体用法?Java LinearLayout.setOrientation怎么用?Java LinearLayout.setOrientation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.LinearLayout
的用法示例。
在下文中一共展示了LinearLayout.setOrientation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ScrollSlidingTabStrip
import android.widget.LinearLayout; //导入方法依赖的package包/类
public ScrollSlidingTabStrip(Context context) {
super(context);
setFillViewport(true);
setWillNotDraw(false);
setHorizontalScrollBarEnabled(false);
tabsContainer = new LinearLayout(context);
tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
addView(tabsContainer);
rectPaint = new Paint();
rectPaint.setAntiAlias(true);
rectPaint.setStyle(Style.FILL);
defaultTabLayoutParams = new LinearLayout.LayoutParams(AndroidUtilities.dp(52), LayoutHelper.MATCH_PARENT);
}
示例2: initViewPage
import android.widget.LinearLayout; //导入方法依赖的package包/类
private void initViewPage() {
setOrientation(VERTICAL);
_viewPager = new ViewPager(_context);
_llDot = new LinearLayout(_context);
LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT,
CommonUtil.getDefaultPannelHeight(_context));
params.gravity=Gravity.BOTTOM;
_viewPager.setLayoutParams(params);
_llDot.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT));
_llDot.setGravity(Gravity.CENTER);
_llDot.setOrientation(HORIZONTAL);
addView(_viewPager);
addView(_llDot);
}
示例3: show
import android.widget.LinearLayout; //导入方法依赖的package包/类
public LinearLayout show() {
final LinearLayout mainLayout = new LinearLayout(this.ctx);
final MenuItem that = this;
this.articleView.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_DOWN) {
mainLayout.setBackgroundColor(Color.parseColor("#EEEEEE"));
}
if(event.getAction() == MotionEvent.ACTION_UP) {
mainLayout.setBackgroundColor(Color.WHITE);
if(event.getX() > 0 && event.getY() > 0 && event.getX() < Utils.dip2px(that.ctx, 200) && event.getY() < Utils.dip2px(that.ctx, 25)) {
if(that.listener != null) that.listener.onClick(v);
}
}
return true;
}
});
mainLayout.setOrientation(0);
mainLayout.setLayoutParams(new LinearLayout.LayoutParams(Utils.dip2px(this.ctx, 200), Utils.dip2px(this.ctx, 25)));
mainLayout.addView(this.iconView);
mainLayout.addView(this.articleView);
return mainLayout;
}
示例4: drawOtherRowFirstCol
import android.widget.LinearLayout; //导入方法依赖的package包/类
/**
* 绘制其他行的第一列,即课程节数
*
* @param scrollContentView
*/
private void drawOtherRowFirstCol(LinearLayout scrollContentView) {
sideView = new LinearLayout(getContext());
LinearLayout.LayoutParams sideViewLP = new LinearLayout.LayoutParams(firstColumnWidth, android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
sideView.setLayoutParams(sideViewLP);
sideView.setOrientation(LinearLayout.VERTICAL);
scrollContentView.addView(sideView);
for (int i = 0; i < showJiesNum; i++) {
View jieciTV=mAdapter.getPeriodView(i+1+"");
// TextView jieciTV = new TextView(getContext());
LinearLayout.LayoutParams jieciTVLP = new LinearLayout.LayoutParams(firstColumnWidth, notFirstEveryRowHeight);
jieciTV.setLayoutParams(jieciTVLP);
jieciTV.setBackgroundResource(R.drawable.side_view_back);
// jieciTV.setText("" + (i + 1));
// jieciTV.setGravity(Gravity.CENTER);
// jieciTV.setTextColor(Color.GRAY);
sideView.addView(jieciTV);
}
}
示例5: addItem
import android.widget.LinearLayout; //导入方法依赖的package包/类
private void addItem(SwipeMenuItem item, int id) {
LayoutParams params = new LayoutParams(item.getWidth(),
LayoutParams.MATCH_PARENT);
LinearLayout parent = new LinearLayout(getContext());
parent.setId(id);
parent.setGravity(Gravity.CENTER);
parent.setOrientation(LinearLayout.VERTICAL);
parent.setLayoutParams(params);
parent.setBackgroundDrawable(item.getBackground());
parent.setOnClickListener(this);
addView(parent);
if (item.getIcon() != null) {
parent.addView(createIcon(item));
}
if (!TextUtils.isEmpty(item.getTitle())) {
parent.addView(createTitle(item));
}
}
示例6: init
import android.widget.LinearLayout; //导入方法依赖的package包/类
/**
* 初始化
*/
private void init(Context context) {
inflater = LayoutInflater.from(context);
// 1. 初始化allLayout
allLayout = new LinearLayout(context);
allLayout.setOrientation(LinearLayout.VERTICAL);
//allLayout.setBackgroundColor(Color.WHITE);//去掉背景
LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
allLayout.setPadding(50, 15, 50, 15);//设置间距,防止生成图片时文字太靠边
addView(allLayout, layoutParams);
LinearLayout.LayoutParams firstEditParam = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
//editNormalPadding = dip2px(EDIT_PADDING);
TextView firstText = createTextView("没有内容", dip2px(context, EDIT_PADDING));
allLayout.addView(firstText, firstEditParam);
}
示例7: initWithSelected
import android.widget.LinearLayout; //导入方法依赖的package包/类
private void initWithSelected(Context context, int selected){
//Add line behind
if(mNumberOfDays > 0){
LayoutParams lineParams =new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,4);
mLine= new View(context);
mLine.setLayoutParams(lineParams);
mLine.setBackgroundColor(ContextCompat.getColor(context,R.color.week_picker_inactive));
addView(mLine,lineParams);
}
//Create container layout
mBulletsLayout = new LinearLayout(context);
mBulletsLayout.setOrientation(LinearLayout.HORIZONTAL);
//Setup size
LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT,getContext().getResources().getDimensionPixelSize(R.dimen.week_picker_height));
mBulletsLayout.setLayoutParams(params);
//Add layout to root view
addView(mBulletsLayout);
//Create items for each day
Calendar c = Calendar.getInstance();
// Set the calendar to monday of the current week
c.setFirstDayOfWeek(Calendar.MONDAY);
c.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
setDatesStartingIn(context,c.getTime(),new Date());
}
示例8: DropDownMenu
import android.widget.LinearLayout; //导入方法依赖的package包/类
public DropDownMenu(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
setOrientation(VERTICAL);
//为DropDownMenu添加自定义属性
int menuBackgroundColor = 0xffffffff;
int underlineColor = 0xffcccccc;
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DropDownMenu);
underlineColor = a.getColor(R.styleable.DropDownMenu_ddunderlineColor, underlineColor);
dividerColor = a.getColor(R.styleable.DropDownMenu_dddividerColor, dividerColor);
textSelectedColor = a.getColor(R.styleable.DropDownMenu_ddtextSelectedColor, textSelectedColor);
textUnselectedColor = a.getColor(R.styleable.DropDownMenu_ddtextUnselectedColor, textUnselectedColor);
menuBackgroundColor = a.getColor(R.styleable.DropDownMenu_ddmenuBackgroundColor, menuBackgroundColor);
maskColor = a.getColor(R.styleable.DropDownMenu_ddmaskColor, maskColor);
menuTextSize = a.getDimensionPixelSize(R.styleable.DropDownMenu_ddmenuTextSize, menuTextSize);
menuSelectedIcon = a.getResourceId(R.styleable.DropDownMenu_ddmenuSelectedIcon, menuSelectedIcon);
menuUnselectedIcon = a.getResourceId(R.styleable.DropDownMenu_ddmenuUnselectedIcon, menuUnselectedIcon);
a.recycle();
//初始化tabMenuView并添加到tabMenuView
tabMenuView = new LinearLayout(context);
LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
tabMenuView.setOrientation(HORIZONTAL);
tabMenuView.setBackgroundColor(menuBackgroundColor);
tabMenuView.setLayoutParams(params);
addView(tabMenuView, 0);
//为tabMenuView添加下划线
View underLine = new View(getContext());
underLine.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dpTpPx(1.0f)));
underLine.setBackgroundColor(underlineColor);
addView(underLine, 1);
//初始化containerView并将其添加到DropDownMenu
containerView = new FrameLayout(context);
containerView.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
addView(containerView, 2);
}
示例9: getVideoLoadingProgressView
import android.widget.LinearLayout; //导入方法依赖的package包/类
@Override
/**
* Ask the host application for a custom progress view to show while
* a <video> is loading.
* @return View The progress view.
*/
public View getVideoLoadingProgressView() {
if (mVideoProgressView == null) {
// Create a new Loading view programmatically.
// create the linear layout
LinearLayout layout = new LinearLayout(this.appView.getContext());
layout.setOrientation(LinearLayout.VERTICAL);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
layout.setLayoutParams(layoutParams);
// the proress bar
ProgressBar bar = new ProgressBar(this.appView.getContext());
LinearLayout.LayoutParams barLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
barLayoutParams.gravity = Gravity.CENTER;
bar.setLayoutParams(barLayoutParams);
layout.addView(bar);
mVideoProgressView = layout;
}
return mVideoProgressView;
}
示例10: onCreate
import android.widget.LinearLayout; //导入方法依赖的package包/类
public void onCreate() {
super.onCreate();
int screenHeight = ResHelper.getScreenHeight(activity);
float ratio = ((float) screenHeight) / DESIGN_SCREEN_HEIGHT;
maxBodyHeight = 0;
llPage = new LinearLayout(activity);
llPage.setOrientation(LinearLayout.VERTICAL);
activity.setContentView(llPage);
rlTitle = new RelativeLayout(activity);
rlTitle.setBackgroundColor(0xffe6e9ec);
int titleHeight = (int) (DESIGN_TITLE_HEIGHT * ratio);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, titleHeight);
llPage.addView(rlTitle, lp);
initTitle(rlTitle, ratio);
RelativeLayout rlBody = new RelativeLayout(activity);
rlBody.setBackgroundColor(0xffffffff);
lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
llPage.addView(rlBody, lp);
initBody(rlBody, ratio);
LinearLayout llShadow = new LinearLayout(activity);
llShadow.setOrientation(LinearLayout.VERTICAL);
rlBody.addView(llShadow, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
initShadow(llShadow, ratio);
llBottom = new LinearLayout(activity);
llBottom.setOrientation(LinearLayout.VERTICAL);
lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
llPage.addView(llBottom, lp);
initBottom(llBottom, ratio);
}
示例11: initBody
import android.widget.LinearLayout; //导入方法依赖的package包/类
private void initBody(RelativeLayout rlBody, float ratio) {
svContent = new ScrollView(activity);
rlBody.addView(svContent, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
LinearLayout llContent = new LinearLayout(activity);
llContent.setOrientation(LinearLayout.HORIZONTAL);
svContent.addView(llContent, new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
etContent = new EditText(activity);
int padding = (int) (DESIGN_LEFT_PADDING * ratio);
etContent.setPadding(padding, padding, padding, padding);
etContent.setBackgroundDrawable(null);
etContent.setTextColor(0xff3b3b3b);
etContent.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21);
etContent.setText(sp.getText());
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT);
lp.weight = 1;
llContent.addView(etContent, lp);
etContent.addTextChangedListener(this);
rlThumb = new RelativeLayout(activity);
rlThumb.setBackgroundColor(0xff313131);
int thumbWidth = (int) (DESIGN_THUMB_HEIGHT_L * ratio);
int xWidth = (int) (DESIGN_REMOVE_THUMB_HEIGHT_L * ratio);
lp = new LinearLayout.LayoutParams(thumbWidth, thumbWidth);
lp.rightMargin = lp.bottomMargin = lp.topMargin = padding;
llContent.addView(rlThumb, lp);
aivThumb = new AsyncImageView(activity) {
public void onImageGot(String url, Bitmap bm) {
thumb = bm;
super.onImageGot(url, bm);
}
};
aivThumb.setScaleToCropCenter(true);
RelativeLayout.LayoutParams rllp = new RelativeLayout.LayoutParams(thumbWidth, thumbWidth);
rlThumb.addView(aivThumb, rllp);
aivThumb.setOnClickListener(this);
initThumb(aivThumb);
xvRemove = new XView(activity);
xvRemove.setRatio(ratio);
rllp = new RelativeLayout.LayoutParams(xWidth, xWidth);
rllp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
rllp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
rlThumb.addView(xvRemove, rllp);
xvRemove.setOnClickListener(this);
}
示例12: initWholeHeaderView
import android.widget.LinearLayout; //导入方法依赖的package包/类
/**
* 初始化整个头部控件
*/
private void initWholeHeaderView() {
mWholeHeaderView = new LinearLayout(getContext());
mWholeHeaderView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
mWholeHeaderView.setOrientation(LinearLayout.VERTICAL);
addView(mWholeHeaderView);
}
示例13: getVideoLoadingProgressView
import android.widget.LinearLayout; //导入方法依赖的package包/类
@Override
/**
* Ask the host application for a custom progress view to show while
* a <video> is loading.
* @return View The progress view.
*/
public View getVideoLoadingProgressView() {
if (mVideoProgressView == null) {
// Create a new Loading view programmatically.
// create the linear layout
LinearLayout layout = new LinearLayout(parentEngine.getView().getContext());
layout.setOrientation(LinearLayout.VERTICAL);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
layout.setLayoutParams(layoutParams);
// the proress bar
ProgressBar bar = new ProgressBar(parentEngine.getView().getContext());
LinearLayout.LayoutParams barLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
barLayoutParams.gravity = Gravity.CENTER;
bar.setLayoutParams(barLayoutParams);
layout.addView(bar);
mVideoProgressView = layout;
}
return mVideoProgressView;
}
示例14: initView
import android.widget.LinearLayout; //导入方法依赖的package包/类
/**
* 初始化视图控件
*/
private void initView() {
mHandler = new Handler(mContext.getMainLooper());
lp_WW = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
lp_MM = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
DisplayMetrics mDisplayMetrics = mContext.getResources().getDisplayMetrics();
screenWidth = mDisplayMetrics.widthPixels;
screenHeight = mDisplayMetrics.heightPixels;
mTopView = new LinearLayout(mContext);
mTopView.setLayoutParams(lp_MM);
mTopView.setOrientation(LinearLayout.VERTICAL);
mTopView.setGravity(Gravity.CENTER);
mTopView2 = new LinearLayout(mContext);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(screenWidth, screenHeight);
mTopView2.setLayoutParams(params);
mTopView2.setOrientation(LinearLayout.VERTICAL);
mTopView2.setGravity(Gravity.BOTTOM);
mView = new LinearLayout(mContext);
mView.setLayoutParams(lp_MM);
mView.setOrientation(LinearLayout.VERTICAL);
mView.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM);
View gapView = new View(mContext);
gapView.setLayoutParams(new LinearLayout.LayoutParams(screenWidth, screenHeight / 4));
mView.addView(gapView);
mTopView.addView(mTopView2);
mTopView2.addView(mView);
resetDefaultBackgroundAndTextColor();
}
示例15: initBody
import android.widget.LinearLayout; //导入方法依赖的package包/类
private void initBody(RelativeLayout rlBody, float ratio) {
svContent = new ScrollView(activity);
rlBody.addView(svContent, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
LinearLayout llContent = new LinearLayout(activity);
llContent.setOrientation(LinearLayout.VERTICAL);
svContent.addView(llContent, new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
etContent = new EditText(activity);
int padding = (int) (DESIGN_LEFT_PADDING * ratio);
etContent.setPadding(padding, padding, padding, padding);
etContent.setBackgroundDrawable(null);
etContent.setTextColor(0xff3b3b3b);
etContent.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21);
etContent.setText(sp.getText());
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
llContent.addView(etContent, lp);
etContent.addTextChangedListener(this);
rlThumb = new RelativeLayout(activity);
rlThumb.setBackgroundColor(0xff313131);
int thumbWidth = (int) (DESIGN_THUMB_HEIGHT * ratio);
int xWidth = (int) (DESIGN_REMOVE_THUMB_HEIGHT * ratio);
lp = new LinearLayout.LayoutParams(thumbWidth, thumbWidth);
lp.leftMargin = lp.rightMargin = lp.bottomMargin = lp.topMargin = padding;
llContent.addView(rlThumb, lp);
aivThumb = new AsyncImageView(activity) {
public void onImageGot(String url, Bitmap bm) {
thumb = bm;
super.onImageGot(url, bm);
}
};
aivThumb.setScaleToCropCenter(true);
RelativeLayout.LayoutParams rllp = new RelativeLayout.LayoutParams(thumbWidth, thumbWidth);
rlThumb.addView(aivThumb, rllp);
aivThumb.setOnClickListener(this);
initThumb(aivThumb);
xvRemove = new XView(activity);
xvRemove.setRatio(ratio);
rllp = new RelativeLayout.LayoutParams(xWidth, xWidth);
rllp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
rllp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
rlThumb.addView(xvRemove, rllp);
xvRemove.setOnClickListener(this);
}