use of android.widget.RelativeLayout in project android-toolbox by Knickedi.
the class HiddenQuickActionSetup method addAction.
/**
* Add quick action to setup.
*
* @param actionId
* ID which will be reported to {@link OnQuickActionListener} when it is performed
* @param actionDescription
* action description shown when hovered (can be {@code null} for no indicator)
* @param drawable
* drawable for quick action
*
* @return {@code false} if action ID already set
*/
public boolean addAction(int actionId, String actionDescription, Drawable drawable) {
int count = mLinearLayout.getChildCount();
for (int i = 0; i < count; i++) {
if (actionId == ((ActionInfo) mLinearLayout.getChildAt(i).getTag()).id) {
return false;
}
}
ImageView iv = new ImageView(mLinearLayout.getContext());
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(mImageWidth, mImageHeight);
params.addRule(RelativeLayout.CENTER_IN_PARENT);
iv.setLayoutParams(params);
iv.setImageDrawable(drawable);
ActionInfo info = new ActionInfo();
info.id = actionId;
info.description = actionDescription;
RelativeLayout rl = new RelativeLayout(mLinearLayout.getContext());
LinearLayout.LayoutParams params2 = new LinearLayout.LayoutParams(0, LayoutParams.FILL_PARENT);
params2.weight = 1;
rl.setLayoutParams(params2);
rl.addView(iv);
rl.setTag(info);
rl.setOnTouchListener(mTouchListener);
mLinearLayout.addView(rl);
return true;
}
use of android.widget.RelativeLayout in project EssayJoke by qiyei2015.
the class BannerView method initView.
/**
* 初始化View 先添加一个BannerViewPager 再添加一个RelativeLayout 作为子View
* @param context
* @param attrs
* @param defStyleAttr
*/
private void initView(Context context, AttributeSet attrs, int defStyleAttr) {
mContext = context;
mFocusDrawable = new ColorDrawable(Color.RED);
mNormalDrawable = new ColorDrawable(Color.WHITE);
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
mChildLayout = new RelativeLayout(context);
mDotContainer = new LinearLayout(context);
mDescTextView = new TextView(context);
// 1 先添加BannerViewPager
mViewPager = new BannerViewPager(context);
mViewPager.setLayoutParams(layoutParams);
addView(mViewPager);
// 2 添加包含TextView 和DotContainer的子View的子View
// 2.1 设置mChildLayout的布局属性,并添加到FrameLayout中
layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
layoutParams.gravity = Gravity.BOTTOM;
mChildLayout.setLayoutParams(layoutParams);
// 设置padding
mChildLayout.setPadding(dip2px(10), dip2px(5), dip2px(10), dip2px(5));
mChildLayout.setBackgroundColor(Color.GRAY);
// 改变透明度
mChildLayout.getBackground().setAlpha(70);
addView(mChildLayout);
// 2.2 先添加mDescTextView 到mChildLayout中
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
// 左部
params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
mDescTextView.setLayoutParams(params);
mChildLayout.addView(mDescTextView);
// 2.3 添加mDotContainer 默认添加到右侧
params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
// 右部 垂直居中
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
params.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
// 水平排列
mDotContainer.setOrientation(LinearLayout.HORIZONTAL);
mDotContainer.setLayoutParams(params);
mChildLayout.addView(mDotContainer);
}
use of android.widget.RelativeLayout in project remusic by aa112901.
the class SwipeRefreshLayout method createFooterViewContainer.
/**
* 添加底部布局
*/
private void createFooterViewContainer() {
mFooterViewContainer = new RelativeLayout(getContext());
mFooterViewContainer.setVisibility(View.GONE);
addView(mFooterViewContainer);
}
use of android.widget.RelativeLayout in project osm-contributor by jawg.
the class RadioChoiceViewBinder method onBindViewHolder.
@Override
public void onBindViewHolder(TagRadioChoiceHolder holder, final TagItem tagItem) {
// Save holder
this.content = holder.getContent();
holder.setCheckBoxListener(new TagRadioChoiceHolder.CheckBoxListener() {
@Override
public void onCheckBoxSelected(String value) {
tagItem.setValue(value);
if (onTagItemChange != null) {
onTagItemChange.onTagItemUpdated(tagItem);
}
}
});
// Set key text view
holder.getTextViewKey().setText(ParserManager.parseTagName(tagItem.getKey(), holder.getContent().getContext()));
// if Tag is show=false, hide it
if (!tagItem.isShow()) {
((RelativeLayout) holder.getContent().getParent()).setVisibility(View.GONE);
}
// Check if size of possible values are 3, means special action to organize layout
Map<String, String> values = tagItem.getValues();
boolean isFourElements = values.size() == 3;
// List of radio buttons without undefined. Undefined is always showing
RadioButton[] radioButtons = holder.getRadioButtons();
RadioButton undefinedRadioButton = holder.getUndefinedRadioButton();
// If the tag is mandatory, the undefined button is disabled and unchecked
if (tagItem.isMandatory()) {
undefinedRadioButton.setEnabled(false);
undefinedRadioButton.setChecked(false);
} else {
undefinedRadioButton.setChecked(true);
}
// Access element for values
int pos = 0;
for (int i = 0; i < radioButtons.length; i++) {
if (!values.isEmpty()) {
// If values is not empty...
if (isFourElements && i == 1) {
// ... and list contains four values, skip one radio to have a 2/2 side by side printing
radioButtons[i].setVisibility(View.INVISIBLE);
i++;
isFourElements = false;
}
if (pos < values.size()) {
// Set value of radio button and show it
String value = (new ArrayList<>(values.values())).get(pos);
radioButtons[i].setText(value);
radioButtons[i].setVisibility(View.VISIBLE);
// Select radio if value is not undefined
String key = (new ArrayList<>(values.keySet())).get(pos);
if (tagItem.getValue() != null && tagItem.getValue().equals(key)) {
holder.getUndefinedRadioButton().setChecked(false);
radioButtons[i].setChecked(true);
}
pos++;
} else {
// If all values are set, hide radio button not used
radioButtons[i].setVisibility(View.INVISIBLE);
}
}
}
// run validation process
showInvalidityMessage(tagItem);
}
use of android.widget.RelativeLayout in project wigle-wifi-wardriving by wiglenet.
the class DBResultActivity method setupMap.
private void setupMap(final LatLng center, final Bundle savedInstanceState) {
mapView = new MapView(this);
mapView.onCreate(savedInstanceState);
MapsInitializer.initialize(this);
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(final GoogleMap googleMap) {
mapRender = new MapRender(DBResultActivity.this, googleMap, true);
if (center != null) {
final CameraPosition cameraPosition = new CameraPosition.Builder().target(center).zoom(DEFAULT_ZOOM).build();
googleMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
}
}
});
final RelativeLayout rlView = (RelativeLayout) findViewById(R.id.db_map_rl);
rlView.addView(mapView);
}
Aggregations