android.widget.RelativeLayout.LayoutParams#WRAP_CONTENT源码实例Demo

下面列出了android.widget.RelativeLayout.LayoutParams#WRAP_CONTENT 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: douyin   文件: InfoAdapter.java
@Override
public View onCreateView(LayoutInflater layoutInflater, ViewGroup parent, int viewType) {
    RelativeLayout layout = new RelativeLayout(getContext());
    LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, dp2px(45));
    layout.setLayoutParams(layoutParams);

    TextView title = new TextView(getContext());
    title.setId(0);
    LayoutParams title_params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    title_params.addRule(RelativeLayout.CENTER_VERTICAL);
    title_params.setMargins(dp2px(18), 0, 0, 0);
    title.setLayoutParams(title_params);

    TextView subTitle = new TextView(getContext());
    subTitle.setId(1);
    LayoutParams subTitle_params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    subTitle_params.addRule(RelativeLayout.CENTER_VERTICAL);
    subTitle_params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    subTitle_params.setMargins(0, 0, dp2px(20), 0);
    subTitle.setLayoutParams(subTitle_params);

    layout.addView(title);
    layout.addView(subTitle);
    return layout;
}
 
源代码2 项目: PanoramaGL   文件: PLView.java
/**
    * This event is fired when GLSurfaceView is created
    * @param glSurfaceView current GLSurfaceView
    */
@SuppressWarnings("deprecation")
protected View onGLSurfaceViewCreated(GLSurfaceView glSurfaceView)
{
	for(int i = 0; i < kMaxTouches; i++)
		mInternalTouches.add(new UITouch(glSurfaceView, new CGPoint(0.0f, 0.0f)));
	mContentLayout = new RelativeLayout(this);
	mContentLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
	mContentLayout.addView(glSurfaceView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
	LayoutParams progressBarLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	progressBarLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
	mProgressBar = new ProgressBar(this);
	mProgressBar.setIndeterminate(true);
	mProgressBar.setVisibility(View.GONE);
	mContentLayout.addView(mProgressBar, progressBarLayoutParams);
	return this.onContentViewCreated(mContentLayout);
}
 
源代码3 项目: CoreModule   文件: BrowserDelegate.java
@Override
public void initWidget() {
    super.initWidget();
    webView = get(R.id.webview);
    mLayoutBottom = (LinearLayout) View.inflate(getActivity(),
            R.layout.item_browser_bottombar, null);
    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams
            .WRAP_CONTENT);
    params.leftMargin = 60;
    params.rightMargin = 60;
    params.bottomMargin = 30;
    params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    ((RelativeLayout) get(R.id.browser_root)).addView(mLayoutBottom, 1, params);
    mLayoutBottom.setVisibility(View.GONE);

    new BrowserDelegateOption(this, linkDispatcher).initWebView();
}
 
源代码4 项目: MaterialQQLite   文件: ChatActivity.java
private void initDotBar() {
        m_arrDotView = new ArrayList<ImageView>();

        if (m_arrFacePageView.size() <= 3)
            return;

        for (int i = 0; i < m_arrFacePageView.size()-2; i++) {
            ImageView imgView = new ImageView(this);
            imgView.setBackgroundResource(R.drawable.common_indicator_nor);
            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                    new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT,
                            LayoutParams.WRAP_CONTENT));
            params.leftMargin = (int)getResources().getDimension(R.dimen.dotLeftMargin);
            params.rightMargin = (int)getResources().getDimension(R.dimen.dotRightMargin);
//			params.width = 7;
//			params.height = 7;
            m_dotBar.addView(imgView, params);
            m_arrDotView.add(imgView);
        }
    }
 
源代码5 项目: panoramagl   文件: PLManager.java
/**
 * This event is fired when GLSurfaceView is created
 *
 * @param glSurfaceView current GLSurfaceView
 */
@SuppressWarnings("deprecation")
protected View onGLSurfaceViewCreated(GLSurfaceView glSurfaceView) {
    for (int i = 0; i < kMaxTouches; i++)
        mInternalTouches.add(new UITouch(glSurfaceView, new CGPoint(0.0f, 0.0f)));
    mContentLayout = new RelativeLayout(context);
    mContentLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    mContentLayout.addView(glSurfaceView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    LayoutParams progressBarLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    progressBarLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
    mProgressBar = new ProgressBar(context);
    mProgressBar.setIndeterminate(true);
    mProgressBar.setVisibility(View.GONE);
    mContentLayout.addView(mProgressBar, progressBarLayoutParams);
    return this.onContentViewCreated(mContentLayout);
}
 
源代码6 项目: panoramagl   文件: PLView.java
/**
 * This event is fired when GLSurfaceView is created
 *
 * @param glSurfaceView current GLSurfaceView
 */
@SuppressWarnings("deprecation")
protected View onGLSurfaceViewCreated(GLSurfaceView glSurfaceView) {
    for (int i = 0; i < kMaxTouches; i++)
        mInternalTouches.add(new UITouch(glSurfaceView, new CGPoint(0.0f, 0.0f)));
    mContentLayout = new RelativeLayout(this);
    mContentLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    mContentLayout.addView(glSurfaceView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    LayoutParams progressBarLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    progressBarLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
    mProgressBar = new ProgressBar(this);
    mProgressBar.setIndeterminate(true);
    mProgressBar.setVisibility(View.GONE);
    mContentLayout.addView(mProgressBar, progressBarLayoutParams);
    return this.onContentViewCreated(mContentLayout);
}
 
源代码7 项目: RePlugin-GameSdk   文件: FunRegistActivity.java
@Override
protected void onPreExecute() {
	super.onPreExecute();
	registProgressBar = new ProgressBar(FunRegistActivity.this, null,
			android.R.attr.progressBarStyle);
	registProgressBar.setVisibility(View.VISIBLE);

	LayoutParams progressBarParams = new LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	progressBarParams.addRule(RelativeLayout.CENTER_IN_PARENT);
	registRelativeLayout.addView(registProgressBar, progressBarParams);
}
 
源代码8 项目: RePlugin-GameSdk   文件: FunLoginActivity.java
@Override
protected void onPreExecute() {
	super.onPreExecute();
	loginProgressBar = new ProgressBar(FunLoginActivity.this, null,
			android.R.attr.progressBarStyle);
	loginProgressBar.setVisibility(View.VISIBLE);

	LayoutParams progressBarParams = new LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	progressBarParams.addRule(RelativeLayout.CENTER_IN_PARENT);
	loginRelativeLayout.addView(loginProgressBar, progressBarParams);
}
 
源代码9 项目: financisto   文件: NodeInflater.java
public EditBuilder(LinearLayout layout, View view) {
    super(layout, R.layout.select_entry_edit);
    RelativeLayout relativeLayout = v.findViewById(R.id.layout);
    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    layoutParams.addRule(RelativeLayout.ALIGN_LEFT, R.id.label);
    layoutParams.addRule(RelativeLayout.BELOW, R.id.label);
    relativeLayout.addView(view, layoutParams);
}
 
源代码10 项目: school_shop   文件: TagViewRight.java
private void initMove() {
		OnTouchListener onTouchListener = new OnTouchListener() {
			
			@Override
			public boolean onTouch(View v, MotionEvent event) {
				switch (event.getAction()) {
				case MotionEvent.ACTION_DOWN:
					lastX=(int)event.getRawX();
		            lastY=(int)event.getRawY();
//		            System.out.println("lastX="+lastX);
					break;
				case MotionEvent.ACTION_MOVE:
					int area = rLayout.getHeight();
					int dx=(int)event.getRawX()-lastX;
		            int dy=(int)event.getRawY()-lastY;
		            int top=v.getTop()+dy;
		            int left=v.getLeft()+dx;
		            if(top<=0) top=0;
		            if(left<=0) left=0;
//		            System.out.println("screenHeight="+screenHeight);
		            if(top>=screenHeight-area)
		            {
		                top=screenHeight-area;
		            }
		            if(left>=screenWidth-rLayout.getWidth())
		            {
		                left=screenWidth-rLayout.getWidth();
		            }
//		            System.out.println("left="+left+"top="+top);
//		            v.layout(left, top, left+rLayout.getWidth(), top+area);
		            LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		            lp.setMargins(left, top, left+rLayout.getWidth(), top+area);
		            v.setLayoutParams(lp);
		            position.setXplace(left);
		            position.setYplace(top);
		            lastX=(int)event.getRawX();
		            lastY=(int)event.getRawY();
		            break;
		          case MotionEvent.ACTION_UP:
		        	  break;
				}
				return false;
			}
		};
		
		rLayout.setOnTouchListener(onTouchListener);
	}
 
源代码11 项目: AndroidFaceRecognizer   文件: MainPageActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.main_page);
	
	
	adView = new AdView(this);
	adView.setAdUnitId("ca-app-pub-4147454460675251/3837655321");
	adView.setAdSize(AdSize.BANNER);
	
	adView.setAdListener(adListener);
	
	RelativeLayout adLayout = (RelativeLayout)findViewById(R.id.main_page_adview_layout);
	adLayout.addView(adView);
	
	RelativeLayout.LayoutParams adViewlp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	adViewlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
	adViewlp.addRule(RelativeLayout.CENTER_HORIZONTAL);
	adView.setLayoutParams(adViewlp);

	
	AdRequest request = new AdRequest.Builder()
	.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
    .addTestDevice("04E14595EE84A505616E50A99B15252D")
    .build();
	
	
	adView.loadAd(request);
	
	System.out.println("---------------------- istestdevice: "+request.isTestDevice(this));

	
	mContext = this;
	
	DisplayMetrics dm = new DisplayMetrics();
	getWindowManager().getDefaultDisplay().getMetrics( dm );
	
	screenWidth = dm.widthPixels;
	screenHeight = dm.heightPixels;
	
	final TextView headerText = (TextView)findViewById(R.id.mainHeaderText);
	RelativeLayout.LayoutParams headerTextParams = (RelativeLayout.LayoutParams)headerText.getLayoutParams();
	headerTextParams.leftMargin = screenHeight/8;
	headerText.setLayoutParams(headerTextParams);
	headerText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, (float)screenHeight/35);
	headerText.setText("Face Recognition");
	headerText.setTextColor(Color.LTGRAY);
	headerText.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
	headerText.setTypeface(null, Typeface.BOLD);
	
	ImageView headerIcon = (ImageView)findViewById(R.id.mainHeaderIcon);
	RelativeLayout.LayoutParams iconLParams = new RelativeLayout.LayoutParams(screenHeight/11, screenHeight/11);
	iconLParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT | RelativeLayout.CENTER_VERTICAL);
	iconLParams.leftMargin = screenHeight/80;
	headerIcon.setLayoutParams(iconLParams);
	
	
	ListView listView = (ListView)findViewById(R.id.mainListView);
	ListAdapter listAdapter = new ListAdapter();
	listView.setAdapter(listAdapter);
	listView.setOnItemClickListener(itemClickListener);
	
	RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)listView.getLayoutParams();
	params.leftMargin = screenWidth/10;
	params.rightMargin = screenWidth/10;
	params.topMargin = screenHeight/12;
	listView.setLayoutParams(params);
	listView.setVerticalScrollBarEnabled(false);

}
 
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	
	// Remove title bar
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
	
	// Intent
	Intent intent = getIntent();
	Log.i(TAG, "Intent: "+intent.getAction()+" / "+intent.hasExtra(ACTION_HIDE_PROGRESS));
	if (intent.hasExtra(ACTION_HIDE_PROGRESS)) {
		finish();
		this.overridePendingTransition(0, 0);
		
		return;
	}
	
	// Parameters
	Bundle extras = intent.getExtras();
	boolean showOverlay = extras == null || extras.getBoolean(EXTRA_SHOW_OVERLAY, true);
	boolean isFullscreen = extras != null && extras.getBoolean(EXTRA_IS_FULLSCREEN, false);

	// Fullscreen
	if (isFullscreen) {
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
	}

	// ProgressBar
	ProgressBar bar = new ProgressBar(this, null, android.R.attr.progressBarStyleLarge);
	RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	params.addRule(RelativeLayout.CENTER_IN_PARENT);
	bar.setLayoutParams(params);
	bar.setBackgroundColor(Color.TRANSPARENT);
	
	// Layout
	RelativeLayout layout = new RelativeLayout(this);
	if (showOverlay) layout.setBackgroundColor(Color.parseColor("#aa000000"));
	layout.addView(bar);
	
	// Theme
	setTheme(android.R.style.Theme_Translucent_NoTitleBar);
	setContentView(layout);
}
 
源代码13 项目: android-empty-layout   文件: EmptyLayout.java
private void changeEmptyType() {
	
	setDefaultValues();
	refreshMessages();

	// insert views in the root view
	if (!mViewsAdded) {
		RelativeLayout.LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		lp.addRule(RelativeLayout.CENTER_HORIZONTAL);
		lp.addRule(RelativeLayout.CENTER_VERTICAL);
		RelativeLayout rl = new RelativeLayout(mContext);
		rl.setLayoutParams(lp);
		if (mEmptyView!=null) rl.addView(mEmptyView);
		if (mLoadingView!=null) rl.addView(mLoadingView);
		if (mErrorView!=null) rl.addView(mErrorView);
		mViewsAdded = true;			

		ViewGroup parent = (ViewGroup) mListView.getParent();
		parent.addView(rl);
		mListView.setEmptyView(rl);
	}
	
	
	// change empty type
	if (mListView!=null) {
		View loadingAnimationView = null;
		if (mLoadingAnimationViewId > 0) loadingAnimationView = ((Activity) mContext).findViewById(mLoadingAnimationViewId); 
		switch (mEmptyType) {
		case TYPE_EMPTY:
			if (mEmptyView!=null) mEmptyView.setVisibility(View.VISIBLE);
			if (mErrorView!=null) mErrorView.setVisibility(View.GONE);
			if (mLoadingView!=null) {
				mLoadingView.setVisibility(View.GONE); 
				if (loadingAnimationView!=null && loadingAnimationView.getAnimation()!=null) loadingAnimationView.getAnimation().cancel();
			}
			break;
		case TYPE_ERROR:
			if (mEmptyView!=null) mEmptyView.setVisibility(View.GONE);
			if (mErrorView!=null) mErrorView.setVisibility(View.VISIBLE);
			if (mLoadingView!=null) {
				mLoadingView.setVisibility(View.GONE); 
				if (loadingAnimationView!=null && loadingAnimationView.getAnimation()!=null) loadingAnimationView.getAnimation().cancel();
			}
			break;
		case TYPE_LOADING:
			if (mEmptyView!=null) mEmptyView.setVisibility(View.GONE);
			if (mErrorView!=null) mErrorView.setVisibility(View.GONE);
			if (mLoadingView!=null) {
				mLoadingView.setVisibility(View.VISIBLE);
				if (mLoadingAnimation != null && loadingAnimationView!=null) {
					loadingAnimationView.startAnimation(mLoadingAnimation);
				}
				else if (loadingAnimationView!=null) {
					loadingAnimationView.startAnimation(getRotateAnimation());
				}
			}				
			break;
		default:
			break;
		}
	}
}