Skip to content

Commit

Permalink
按钮添加内边距
Browse files Browse the repository at this point in the history
  • Loading branch information
liyujiang-gzu committed Dec 18, 2016
1 parent 96de796 commit ce71bb5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ dependencies {
选择器内嵌到其他视图容器:
```java
final CarNumberPicker picker = new CarNumberPicker(this);
picker.setWidth(picker.getScreenWidthPixels() / 2);
picker.setLineConfig(new WheelView.LineConfig(0));//使用最长的分割线
picker.setOnWheelListener(new CarNumberPicker.OnWheelListener() {
@Override
public void onFirstWheeled(int index, String item) {
Expand Down Expand Up @@ -217,7 +215,7 @@ dependencies {
picker.show();
```

星座选择器(参见ConstellationPicker)
星座选择器:
```java
boolean isChinese = Locale.getDefault().getDisplayLanguage().contains("中文");
OptionPicker picker = new OptionPicker(this,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,16 @@ protected View makeHeaderView() {
topButtonLayout.setBackgroundColor(topBackgroundColor);
topButtonLayout.setGravity(Gravity.CENTER_VERTICAL);

int padding = ConvertUtils.toPx(activity, 10);
Button cancelButton = new Button(activity);
cancelButton.setVisibility(cancelVisible ? View.VISIBLE : View.GONE);
RelativeLayout.LayoutParams cancelButtonLayoutParams = new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
RelativeLayout.LayoutParams cancelButtonLayoutParams = new RelativeLayout.LayoutParams(WRAP_CONTENT, MATCH_PARENT);
cancelButtonLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
cancelButtonLayoutParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
cancelButton.setLayoutParams(cancelButtonLayoutParams);
cancelButton.setBackgroundColor(Color.TRANSPARENT);
cancelButton.setGravity(Gravity.CENTER);
cancelButton.setPadding(padding, 0, padding, 0);
if (!TextUtils.isEmpty(cancelText)) {
cancelButton.setText(cancelText);
}
Expand Down Expand Up @@ -269,12 +271,13 @@ public void onClick(View v) {
topButtonLayout.addView(titleView);

Button submitButton = new Button(activity);
RelativeLayout.LayoutParams submitButtonLayoutParams = new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
RelativeLayout.LayoutParams submitButtonLayoutParams = new RelativeLayout.LayoutParams(WRAP_CONTENT, MATCH_PARENT);
submitButtonLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
submitButtonLayoutParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
submitButton.setLayoutParams(submitButtonLayoutParams);
submitButton.setBackgroundColor(Color.TRANSPARENT);
submitButton.setGravity(Gravity.CENTER);
submitButton.setPadding(padding, 0, padding, 0);
if (!TextUtils.isEmpty(submitText)) {
submitButton.setText(submitText);
}
Expand Down

0 comments on commit ce71bb5

Please sign in to comment.