我正在制作一个微调器但是我在将图像放入旋转器时遇到了麻烦。 我想要这样的微调器:
在哪里给了外壳和插件,但我不知道该怎么做..可以帮助。
这是我的xml文件:
public class SubMenu extends AppCompatActivity {
JSONObject jsonobject;
JSONArray jsonarray;
ListView listview;
ListViewAdapter adapter;
ProgressDialog mProgressDialog;
ArrayList<HashMap<String, String>> arraylist;
static String RANK = "id";
static String COUNTRY = "name";
static String FLAG = "image";
Integer i = 1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sub_menu);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
String SelectedId = getIntent().getStringExtra("id");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// Get the view from listview_main.xml
// Execute DownloadJSON AsyncTask
new DownloadJSON().execute();
}
// DownloadJSON AsyncTask
private class DownloadJSON extends AsyncTask<Void, Void, Void> implements AdapterView.OnItemClickListener {
// @Override
// protected void onPreExecute() {
// super.onPreExecute();
// Create a progressdialog
// mProgressDialog = new ProgressDialog(SubMenu.this);
// Set progressdialog title
// mProgressDialog.setTitle("Categories of Main categories.....");
// Set progressdialog message
// mProgressDialog.setMessage("Loading...");
// mProgressDialog.setIndeterminate(false);
// Show progressdialog
// mProgressDialog.show();
// }
@Override
protected Void doInBackground(Void... params) {
// Create an array
arraylist = new ArrayList<HashMap<String, String>>();
// Retrieve JSON Objects from the given URL address
jsonarray = JsonFunctions
.getJSONfromURL("http://cloud....com/broccoli/menu_typeitem.php?id=" + getIntent().getStringExtra("id"));
try {
// Locate the array name in JSON
// jsonarray = jsonobject.getJSONArray("main_menu_items");
for (int i = 0; i < jsonarray.length(); i++) {
HashMap<String, String> map = new HashMap<String, String>();
jsonobject = jsonarray.getJSONObject(i);
// Retrive JSON Objects
// map.put("id", jsonobject.getString("id"));
map.put("name", jsonobject.getString("name"));
map.put("image", jsonobject.getString("image"));
// Set the JSON Objects into the array
arraylist.add(map);
}
} catch (JSONException e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void args) {
// Locate the listview in listview_main.xml
listview = (ListView) findViewById(R.id.list1);
// Pass the results into ListViewAdapter.java
adapter = new ListViewAdapter(SubMenu.this, arraylist);
// Set the adapter to the ListView
listview.setAdapter(adapter);
listview.setOnItemClickListener(this);
// Close the progressdialog
// mProgressDialog.dismiss();
}
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long rowId) {
final AlertDialog customDialog = new AlertDialog.Builder(SubMenu.this).create();
final LayoutInflater inflater = getLayoutInflater();
final View dialogView = inflater.inflate(R.layout.popup
, null);
customDialog.setView(dialogView);
// set the custom customDialogimation components - text, image and button
final TextView tvDistance = (TextView) dialogView.findViewById(R.id.h2);
final Button ok = (Button) dialogView.findViewById(R.id.ok);
ok.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
customDialog.dismiss();
}
});
final Button cncl = (Button) dialogView.findViewById(R.id.canc);
cncl.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
customDialog.dismiss();
}
});
Button _decrease = (Button) dialogView.findViewById(R.id.incr);
Button _increase = (Button) dialogView.findViewById(R.id.decr);
final TextView _value = (TextView) dialogView.findViewById(R.id.value);
i = Integer.parseInt(_value.getText().toString());
_decrease.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String _stringVal;
Log.d("src", "Decreasing value...");
if (i > 0) {
i = i - 1;
_stringVal = String.valueOf(i);
_value.setText(_stringVal);
} else {
Log.d("src", "Value can't be less than 0");
}
}
});
_increase.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String _stringVal;
Log.d("src", "Increasing value...");
i = i + 1;
_stringVal = String.valueOf(i);
_value.setText(_stringVal);
}
});
customDialog.show();
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
这是我的SubMenu活动:
repeatInterval
在tahmid的回答之后,它看起来像这样:
透明度后我编辑过的图像
答案 0 :(得分:2)
在Spinner
中,您可以在drawable中尝试选择器xml(spinner_selector.xml)文件。
在此选择器xml中,您可以为微调器的选定和未选定状态定义图像。如下
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/spinner_pressed" />
<item android:drawable="@drawable/spinner_normal" />
</selector>
然后在你的微调器中添加选择器作为背景,
<Spinner
android:id="@+id/spinner"
android:layout_width="match_parent"
android:background="@drawable/spinner_selector"
android:layout_height="match_parent"
android:layout_margin="5dp" />
希望它有所帮助!
对于您的布局问题,请复制新的xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:orientation="vertical">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="-50dp" >
<!---add your views here-->
</LinearLayout>
<ImageView
android:id="@+id/imageView_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|right"
android:clickable="true"
android:background="@drawable/crss" />
</FrameLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp">
<ImageView
android:id="@+id/desimage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="@drawable/logo" />
<TextView
android:id="@+id/h1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="Chicken Pizza Small"
android:textSize="21sp"
android:textStyle="bold" />
<TextView
android:id="@+id/h2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="Chicken Pizza Small Combo"
android:textColor="#8c8181"
android:textSize="16sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:weightSum="10">
<Button
android:id="@+id/quant"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginRight="10dp"
android:layout_weight="3"
android:background="@drawable/mybutton"
android:text="Quantity"
android:textAllCaps="false"
android:textColor="#ffffff" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="7"
android:background="@drawable/stroke_button"
android:orientation="horizontal"
android:weightSum="3">
<Button
android:id="@+id/incr"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:text="-"
android:textColor="#FFA726"
android:textSize="25dp" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#c0c0c0" />
<TextView
android:id="@+id/value"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:inputType="number"
android:text="1" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#c0c0c0" />
<Button
android:id="@+id/decr"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:text="+"
android:textColor="#FFA726"
android:textSize="25dp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp">
<CheckBox
android:id="@+id/sl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:buttonTint="#c0c0c0"
android:text="SL"
android:textColor="#8c8181"
tools:targetApi="lollipop" />
<CheckBox
android:id="@+id/s"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:buttonTint="#c0c0c0"
android:text="S"
android:textColor="#8c8181"
tools:targetApi="lollipop" />
<CheckBox
android:id="@+id/m"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:buttonTint="#c0c0c0"
android:text="M"
android:textColor="#8c8181"
tools:targetApi="lollipop" />
<CheckBox
android:id="@+id/L"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:buttonTint="#c0c0c0"
android:text="l"
android:textColor="#8c8181"
tools:targetApi="lollipop" />
<CheckBox
android:id="@+id/f"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:buttonTint="#c0c0c0"
android:text="F"
android:textColor="#8c8181"
tools:targetApi="lollipop" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:background="#c0c0c0" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="35dp"
android:layout_marginLeft="7dp"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:background="@drawable/stroke_button">
<Spinner
android:id="@+id/spin_1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:textAppearance="?android:attr/textAppearanceSmall" />
<ImageView
android:id="@+id/img_1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:src="@drawable/spinpres" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="35dp"
android:layout_marginLeft="7dp"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:background="@drawable/stroke_button">
<Spinner
android:id="@+id/spin_2"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:textAppearance="?android:attr/textAppearanceSmall" />
<ImageView
android:id="@+id/img_2"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:src="@drawable/spinpres" />
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="SPECIAL INSTRUCTIONS"
android:textSize="16sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:background="@drawable/stroke_button"
android:padding="@dimen/fab_margin1">
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:gravity="top"
android:inputType="textCapSentences|textMultiLine"
android:lines="5"
android:maxLines="5"
android:padding="2dp"
android:textColor="#c0c0c0" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp">
<Button
android:id="@+id/canc"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:background="@drawable/mybutton2"
android:text="Cancel"
android:textColor="#ffffff" />
<Button
android:id="@+id/ok"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:background="@drawable/mybutton"
android:text="Ok"
android:textColor="#ffffff" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
为错误的缩进道歉
答案 1 :(得分:1)
这是我的解决方案
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp">
<ImageView
android:id="@+id/desimage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="@drawable/logo" />
<TextView
android:id="@+id/h1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="Chicken Pizza Small"
android:textSize="21sp"
android:textStyle="bold" />
<TextView
android:id="@+id/h2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="Chicken Pizza Small Combo"
android:textColor="#8c8181"
android:textSize="16sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:weightSum="10">
<Button
android:id="@+id/quant"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginRight="10dp"
android:layout_weight="3"
android:background="@drawable/mybutton"
android:text="Quantity"
android:textAllCaps="false"
android:textColor="#ffffff" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="7"
android:background="@drawable/stroke_button"
android:orientation="horizontal"
android:weightSum="3">
<Button
android:id="@+id/incr"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:text="-"
android:textColor="#FFA726"
android:textSize="25dp" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#c0c0c0" />
<TextView
android:id="@+id/value"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:inputType="number"
android:text="1" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#c0c0c0" />
<Button
android:id="@+id/decr"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:text="+"
android:textColor="#FFA726"
android:textSize="25dp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp">
<CheckBox
android:id="@+id/sl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:buttonTint="#c0c0c0"
android:text="SL"
android:textColor="#8c8181"
tools:targetApi="lollipop" />
<CheckBox
android:id="@+id/s"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:buttonTint="#c0c0c0"
android:text="S"
android:textColor="#8c8181"
tools:targetApi="lollipop" />
<CheckBox
android:id="@+id/m"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:buttonTint="#c0c0c0"
android:text="M"
android:textColor="#8c8181"
tools:targetApi="lollipop" />
<CheckBox
android:id="@+id/L"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:buttonTint="#c0c0c0"
android:text="l"
android:textColor="#8c8181"
tools:targetApi="lollipop" />
<CheckBox
android:id="@+id/f"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:buttonTint="#c0c0c0"
android:text="F"
android:textColor="#8c8181"
tools:targetApi="lollipop" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:background="#c0c0c0" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="35dp"
android:layout_marginLeft="7dp"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:background="@drawable/stroke_button">
<Spinner
android:id="@+id/spin_1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:textAppearance="?android:attr/textAppearanceSmall" />
<ImageView
android:id="@+id/img_1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:src="@drawable/spinpres" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="35dp"
android:layout_marginLeft="7dp"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:background="@drawable/stroke_button">
<Spinner
android:id="@+id/spin_2"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:textAppearance="?android:attr/textAppearanceSmall" />
<ImageView
android:id="@+id/img_2"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:src="@drawable/spinpres" />
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="SPECIAL INSTRUCTIONS"
android:textSize="16sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:background="@drawable/stroke_button"
android:padding="@dimen/fab_margin1">
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:gravity="top"
android:inputType="textCapSentences|textMultiLine"
android:lines="5"
android:maxLines="5"
android:padding="2dp"
android:textColor="#c0c0c0" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp">
<Button
android:id="@+id/canc"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:background="@drawable/mybutton2"
android:text="Cancel"
android:textColor="#ffffff" />
<Button
android:id="@+id/ok"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:background="@drawable/mybutton"
android:text="Ok"
android:textColor="#ffffff" />
</LinearLayout>
</LinearLayout>
</ScrollView>
这里是stroke_button.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FFFFFF" />
<corners android:radius="20dp" />
<stroke
android:width="1dp"
android:color="#c0c0c0" />
</shape>
现在以你想要的方式改变图像... enjot..happy coding
答案 2 :(得分:1)
在这里,我得到了解决方案,请查看新的xml文件
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="400dp"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="15dp"
android:background="#F4F4F4">
<!--Main Body of your custom dialog-->
<ScrollView
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp">
<ImageView
android:id="@+id/desimage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="@drawable/logo" />
<TextView
android:id="@+id/h1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="Chicken Pizza Small"
android:textSize="21sp"
android:textStyle="bold" />
<TextView
android:id="@+id/h2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="Chicken Pizza Small Combo"
android:textColor="#8c8181"
android:textSize="16sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:weightSum="10">
<Button
android:id="@+id/quant"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginRight="10dp"
android:layout_weight="3"
android:background="@drawable/mybutton"
android:text="Quantity"
android:textAllCaps="false"
android:textColor="#ffffff" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="7"
android:background="@drawable/stroke_button"
android:orientation="horizontal"
android:weightSum="3">
<Button
android:id="@+id/incr"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:text="-"
android:textColor="#FFA726"
android:textSize="25dp" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#c0c0c0" />
<TextView
android:id="@+id/value"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:inputType="number"
android:text="1" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#c0c0c0" />
<Button
android:id="@+id/decr"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:text="+"
android:textColor="#FFA726"
android:textSize="25dp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp">
<CheckBox
android:id="@+id/sl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:buttonTint="#c0c0c0"
android:text="SL"
android:textColor="#8c8181"
tools:targetApi="lollipop" />
<CheckBox
android:id="@+id/s"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:buttonTint="#c0c0c0"
android:text="S"
android:textColor="#8c8181"
tools:targetApi="lollipop" />
<CheckBox
android:id="@+id/m"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:buttonTint="#c0c0c0"
android:text="M"
android:textColor="#8c8181"
tools:targetApi="lollipop" />
<CheckBox
android:id="@+id/L"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:buttonTint="#c0c0c0"
android:text="l"
android:textColor="#8c8181"
tools:targetApi="lollipop" />
<CheckBox
android:id="@+id/f"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:buttonTint="#c0c0c0"
android:text="F"
android:textColor="#8c8181"
tools:targetApi="lollipop" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:background="#c0c0c0" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="35dp"
android:layout_marginLeft="7dp"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:background="@drawable/stroke_button">
<Spinner
android:id="@+id/spin_1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:textAppearance="?android:attr/textAppearanceSmall" />
<ImageView
android:id="@+id/img_1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:src="@drawable/spinpres" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="35dp"
android:layout_marginLeft="7dp"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:background="@drawable/stroke_button">
<Spinner
android:id="@+id/spin_2"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:textAppearance="?android:attr/textAppearanceSmall" />
<ImageView
android:id="@+id/img_2"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:src="@drawable/spinpres" />
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="SPECIAL INSTRUCTIONS"
android:textSize="16sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:background="@drawable/stroke_button"
android:padding="@dimen/fab_margin1">
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:gravity="top"
android:inputType="textCapSentences|textMultiLine"
android:lines="5"
android:maxLines="5"
android:padding="2dp"
android:textColor="#c0c0c0" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp">
<Button
android:id="@+id/canc"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:background="@drawable/mybutton2"
android:text="Cancel"
android:textColor="#ffffff" />
<Button
android:id="@+id/ok"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:background="@drawable/mybutton"
android:text="Ok"
android:textColor="#ffffff" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
<LinearLayout
android:id="@+id/llTop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:orientation="vertical">
<ImageButton
android:id="@+id/btnCancel"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_below="@+id/btnBookK"
android:background="@null"
android:src="@drawable/close_button_image" />
</LinearLayout>
</RelativeLayout>
如果你使用透明的背景图像,它看起来会很好;并且不要忘记在构建器中编写以下代码
AlertDialog yourDialog = builder.Create() ;
yourDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
yourDialog.show();
这个代码有效,我试过了。希望它有所帮助!