Don't overlap Pins in com.appyvet.rangebar.RangeBar - android

I am using this library to create Double RangeBar in android. Now in this rangebar i want that if left pin overlaps the right pin it must return to its previous position instead of overlapping and same for right pin. This is same as used in flipkart to filter price ranges.(Flipkart uses Range bar like this). I want to implement same property like that. How can i implement this property. Please help me..
Thanks in advance.
This is my Activity and xml
#Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.range_bar);
min = (TextView)findViewById(R.id.min);
sign_rupees = (TextView)findViewById(R.id.sign_rupees);
sign_rupees2 = (TextView)findViewById(R.id.sign_rupees2);
selected_min = (TextView)findViewById(R.id.selected_min);
selected_max = (TextView)findViewById(R.id.selected_max);
rangeBar = (RangeBar)findViewById(R.id.rangebar3);
rangeBar.setOnRangeBarChangeListener(this);
}
#Override
public void onRangeChangeListener(RangeBar rangeBar, int leftPinIndex, int rightPinIndex, String leftPinValue, String rightPinValue) {
int diff = rightPinIndex-leftPinIndex;
if (diff == 0){
rangeBar.setRangePinsByIndices(leftPinIndex-1,rightPinIndex+1);
rangeBar.setEnabled(true);
}else{
rangeBar.setEnabled(true);
if (leftPinIndex == 0){
min.setText("Min");
min.setVisibility(View.VISIBLE);
sign_rupees.setVisibility(View.INVISIBLE);
selected_min.setVisibility(View.INVISIBLE);
}else{
min.setVisibility(View.GONE);
sign_rupees.setVisibility(View.VISIBLE);
selected_min.setVisibility(View.VISIBLE);
selected_min.setText(String.valueOf(leftPinIndex*500));
}
if (rightPinIndex == 6){
selected_max.setText("2500+");
}else{
selected_max.setText(String.valueOf(rightPinIndex*500));
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:layout_height="match_parent"
android:layout_width="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_margin="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/rangebar1"
android:layout_marginBottom="10dp">
<com.appyvet.rangebar.RangeBar
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:id="#+id/rangebar3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
custom:tickStart="0"
custom:tickInterval="1"
custom:tickEnd="6"
custom:pinRadius="20dp"
custom:pinMinFont="5sp"
custom:textColor="#android:color/transparent"
custom:selectorSize="5dp"/>
</LinearLayout>
<RelativeLayout
android:id="#+id/left_linear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/rangebar1">
<TextView
android:id="#+id/min_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Min Price"
android:textSize="12sp"
android:textColor="#color/grey_dark"
android:layout_margin="10dp"/>
<TextView
android:id="#+id/min"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Min"
android:textColor="#000"
android:layout_marginLeft="10dp"
android:layout_below="#+id/min_price"
android:visibility="visible"
android:textSize="20sp"/>
<TextView
android:id="#+id/sign_rupees"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/rupees_symbol"
android:textColor="#000"
android:layout_marginLeft="10dp"
android:layout_below="#+id/min_price"
android:visibility="invisible"
android:textSize="20sp"/>
<TextView
android:id="#+id/selected_min"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="250"
android:textColor="#000"
android:layout_marginLeft="5dp"
android:layout_below="#+id/min_price"
android:layout_toRightOf="#+id/sign_rupees"
android:visibility="invisible"
android:textSize="20sp"/>
</RelativeLayout>
<RelativeLayout
android:id="#+id/right_linear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignParentRight="true"
android:layout_marginTop="10dp"
android:layout_below="#+id/rangebar1">
<TextView
android:id="#+id/max_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Max Price"
android:textColor="#color/grey_dark"
android:textSize="12sp"
android:layout_alignRight="#+id/rl"/>
<RelativeLayout
android:id="#+id/rl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/max_price"
android:layout_marginTop="10dp">
<TextView
android:id="#+id/sign_rupees2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/rupees_symbol"
android:textColor="#000"
android:textSize="20sp"/>
<TextView
android:id="#+id/selected_max"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2500+"
android:textColor="#000"
android:textSize="20sp"
android:layout_marginLeft="10dp"/>
</RelativeLayout>
</RelativeLayout>

I haven't used this library , but looking at their code what you can try is :
#Override
public void onRangeChangeListener(RangeBar rangeBar, int leftPinIndex, int rightPinIndex, String leftPinValue, String rightPinValue) {
int diff = rightPinIndex-leftPinIndex;
if (diff == 0){
rangeBar.setRangePinsByIndices(leftPinIndex-1,rightPinIndex+1);
rangeBar.setEnabled(true);
}else{
rangeBar.setEnabled(true);
if (leftPinIndex == 0){
min.setText("Min");
min.setVisibility(View.VISIBLE);
sign_rupees.setVisibility(View.INVISIBLE);
selected_min.setVisibility(View.INVISIBLE);
}else{
min.setVisibility(View.GONE);
sign_rupees.setVisibility(View.VISIBLE);
selected_min.setVisibility(View.VISIBLE);
selected_min.setText(String.valueOf(leftPinIndex*500));
}
if (rightPinIndex == 6){
selected_max.setText("2500+");
}else{
selected_max.setText(String.valueOf(rightPinIndex*500));
}
}
if(rightPinIndex <= leftPinIndex) {
rangebar.setRangePinsByIndices(leftIntIndex-5, rightIntIndex+5); // This +-5 value can be anything
}
}

Related

How to position an ImageView in the same place in different screen sizes?

I been working on a simple android app that calculates a person's Body Mass Index, I have all the features working but positioning the arrow in the right place in the color bar corresponding to the user's screen size is what Im stuck on. I have it working by setting the X and Y values of the arrow ImageView but obviously the place of the arrow changes when i test my application in different screen sizes even though im coverting a dp value to pixels. How can I position the arrow ImageView so that it stays the same in different screen sizes?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="coding.guillermo.bmiapp.MainActivity2"
tools:showIn="#layout/activity_main2"
android:clickable="false"
android:background="#ffffff"
android:id="#+id/relativeLayout">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BMI"
android:id="#+id/bmiText"
android:textSize="25dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="21.24"
android:id="#+id/bmiResult"
android:textSize="30dp"
android:layout_below="#+id/bmiText"
android:layout_centerHorizontal="true"
android:layout_marginTop="22dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/bmiCategory"
android:textSize="25dp"
android:text="Normal weight"
android:layout_marginTop="22dp"
android:layout_below="#+id/bmiResult"
android:layout_centerHorizontal="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save result"
android:id="#+id/saveButton"
android:backgroundTint="#color/toolBarColor"
android:textColor="#ffffff"
android:layout_marginBottom="20dp"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BMI Log"
android:id="#+id/trackerButton2"
android:backgroundTint="#color/toolBarColor"
android:textColor="#ffffff"
android:layout_alignTop="#+id/saveButton" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView"
android:background="#drawable/bmibar"
android:layout_marginTop="36dp"
android:layout_below="#+id/bmiCategory" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Underweight <18.50 "
android:id="#+id/underweightText"
android:textSize="22sp"
android:layout_below="#+id/imageView"
android:layout_centerHorizontal="true"
android:layout_marginTop="33dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Normal 18.5 - 24.99"
android:id="#+id/normalText"
android:textSize="22sp"
android:paddingTop="5dp"
android:layout_below="#+id/underweightText"
android:layout_alignStart="#+id/underweightText" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Overweight >=25.00"
android:id="#+id/overweightText"
android:layout_below="#+id/normalText"
android:textSize="22sp"
android:paddingTop="5dp"
android:layout_alignStart="#+id/normalText" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Obese >=30.00"
android:id="#+id/obeseText"
android:textSize="22sp"
android:paddingTop="5dp"
android:layout_below="#+id/overweightText"
android:layout_alignStart="#+id/overweightText" />
public class MainActivity2 extends AppCompatActivity {
TextView resultText,bmiLabel,underWeightText,normalText,overweightText,obeseText;
RelativeLayout.LayoutParams params;
Button saveButton,trackerButton;
Result result;
EditText userName;
DBhandler dbHandler;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
// TextViews
resultText = (TextView) findViewById(R.id.bmiResult);
bmiLabel = (TextView) findViewById(R.id.bmiCategory);
underWeightText = (TextView) findViewById(R.id.underweightText);
normalText = (TextView) findViewById(R.id.normalText);
overweightText = (TextView) findViewById(R.id.overweightText);
obeseText = (TextView) findViewById(R.id.obeseText);
// Button
saveButton = (Button) findViewById(R.id.saveButton);
trackerButton = (Button) findViewById(R.id.trackerButton2);
// Getting User object from the previous activity
result = (Result) getIntent().getParcelableExtra("result");
// Database
dbHandler = new DBhandler(this);
// Displaying the arrow in the corresponding place
ImageView arrow = new ImageView(this);
params = new RelativeLayout.LayoutParams(80,80);
arrow.setImageResource(R.drawable.arrow2);
RelativeLayout rl = (RelativeLayout) findViewById(R.id.relativeLayout);
// the display of the arrow is different when tested in device's with different screen sizes
int dpValue = 0;
int dpValue2 = 166;
float d = getApplicationContext().getResources().getDisplayMetrics().density;
int margin = (int)(dpValue * d);
int margin2 = (int) (dpValue2 * d);
arrow.setX(margin);
arrow.setY(margin2);
rl.addView(arrow);
// BMI diplay
resultText.setText(Double.toString(result.getBMI()));
bmiLabel.setText(result.getBmiCategory());
// BMI category bold display
bmiCategoryBold(result.getBMI());
// Saving result to internal storage for later retrieval
saveButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
View view = (LayoutInflater.from(MainActivity2.this)).inflate(R.layout.alert_content,null);
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(MainActivity2.this);
alertBuilder.setView(view);
userName = (EditText) view.findViewById(R.id.nameInput);
SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
String date = dateFormat.format(new Date());
result.setDate(date);
alertBuilder.setCancelable(true).setPositiveButton("Ok", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
result.setName(userName.getText().toString());
// adding result to the SQLite database
dbHandler.addResult(result);
Toast toast = Toast.makeText(getApplicationContext(),"result saved",Toast.LENGTH_SHORT);
toast.show();
}
});
AlertDialog dialog = alertBuilder.create();
dialog.show();
Button nButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
nButton.setBackgroundColor(getResources().getColor(R.color.toolBarColor));
nButton.setTextColor(Color.WHITE);
}
});
trackerButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(),MainActivity3.class);
startActivity(intent);
}
});
}
public void bmiCategoryBold(double bmi){
if(bmi < 18.50){
underWeightText.setTypeface(null, Typeface.BOLD);
}
else if(bmi <= 24.99){
normalText.setTypeface(null,Typeface.BOLD);
}
else if(bmi<=29.99){
overweightText.setTypeface(null,Typeface.BOLD);
}
else{
obeseText.setTypeface(null,Typeface.BOLD);
}
}
}
The first pic is the app running on 1080 pixels by 1920 pixels screen and the second is a 1440 pixels by 2560 pixels screen
first pic
second pic
Add Linearlayout as subparent of childview,use its orientation and gravity attribute you can easily get the design in more optimize way and suitable for everyscreen size.
here i have used RelativeLayout as Parent and LinearLayout as sub-parent of childview.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:padding="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/bmiText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BMI"
android:textSize="25dp" />
<TextView
android:id="#+id/bmiResult"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="21.24"
android:textSize="30dp" />
<TextView
android:id="#+id/bmiCategory"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Normal weight"
android:textSize="25dp" />
</LinearLayout>
<ImageView
android:id="#+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#mipmap/ic_launcher" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:padding="5dp">
<TextView
android:id="#+id/underweightText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="Underweight <18.50 "
android:textSize="22sp" />
<TextView
android:id="#+id/normalText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="Normal 18.5 - 24.99"
android:textSize="22sp" />
<TextView
android:id="#+id/overweightText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="Overweight >=25.00"
android:textSize="22sp" />
<TextView
android:id="#+id/obeseText"
android:layout_width="wrap_content"
android:padding="10dp"
android:layout_height="wrap_content"
android:text="Obese >=30.00"
android:textSize="22sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:gravity="left"
android:layout_height="wrap_content">
<Button
android:id="#+id/trackerButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="#000000"
android:text="BMI Log"
android:gravity="center"
android:textColor="#ffffff" />
<LinearLayout
android:layout_width="match_parent"
android:gravity="right"
android:layout_height="wrap_content">
<Button
android:id="#+id/saveButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:backgroundTint="#000000"
android:text="Save result"
android:textColor="#ffffff" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Try to avoid too much margin top and bottom.

add blink to customized listview Item?

i have created a listview contains multiple items, and i added a border to those items so it would look like this:
because of this customized border the original blink of an item get blocked so it doesn't appear, and i've tried to add a blink through animation but there is too much delay and too much work on the main thread, i also used animation inside threads but it is the same with the delay thing, which force me to forget about animation so is there anyway that i can make the item blink when its clicked without using animation or with using it but in an efficient way and by the way i used blink animation inside my onItemClickListener you can find it in the code below:
onItemClickListener that handle the blink:
dataList.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> arg0, final View arg1,
final int arg2, long arg3) {
// TODO Auto-generated method stub
tvWarningNoEmp.setVisibility(View.GONE);
// adding blink
final Animation animation = new AlphaAnimation(
1, 0); // Change
// alpha
// from
// fully
// visible
// to
// invisible
animation.setDuration(100); // duration - half a
// second
animation
.setInterpolator(new LinearInterpolator()); // do
// not
// alter
// animation
// rate
animation.setRepeatCount(Animation.INFINITE); // Repeat
// animation
// infinitely
animation.setRepeatMode(Animation.REVERSE);
arg1.startAnimation(animation);
// blink one time timer
new CountDownTimer(100, 100) {// CountDownTimer(edittext1.getText()+edittext2.getText())
// also parse it to long
public void onTick(long millisUntilFinished) {
// here you can have your logic to set text to
// edittext
}
public void onFinish() {
arg1.clearAnimation();
}
}.start();
// set margins for tickets buttons
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
params.setMargins(0, 0, 30, 0);
bAssign.setLayoutParams(params);
LinearLayout.LayoutParams paramsO = new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
paramsO.setMargins(110, 0, 0, 0);
bEmpChat.setLayoutParams(paramsO);
noEmpLayout.setVisibility(LinearLayout.GONE);
empLayout.setVisibility(LinearLayout.VISIBLE);
Employee item = adapter.getItem(arg2);
ivEmpIcon.setBackgroundResource(R.drawable.free);
tvEmpName.setText(" " + item.getEmpName());
tvEmpDetails.setText(" " + item.getEmpDetails());
empLongitude = item.getEmpLongitude();
empLatitude = item.getEmpLatitude();
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(new LatLng(empLatitude, empLongitude))
.zoom(15).build();
googleEmpMap.animateCamera(CameraUpdateFactory
.newCameraPosition(cameraPosition));
MarkerOptions marker = new MarkerOptions().position(
new LatLng(empLatitude, empLongitude)).title(
tvEmpName.getText().toString());
marker.icon(BitmapDescriptorFactory
.defaultMarker(BitmapDescriptorFactory.HUE_RED));
googleEmpMap.addMarker(marker);
// based on item add info to intent
// hide button directions
bEmpDirections.setVisibility(View.GONE);
// current address
Geocoder geocoder;
List<Address> addresses;
geocoder = new Geocoder(getApplicationContext(), Locale
.getDefault());
try {
addresses = geocoder.getFromLocation(empLatitude,
empLongitude, 1);
String street = addresses.get(0).getAddressLine(0);
String state = addresses.get(0).getAdminArea();
String country = addresses.get(0).getCountryName();
tvEmpCurrentAdd.setText(" " + country + "-" + state
+ "-" + street + " st.");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();}
}
});
ListView Layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/redborder" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<Button
android:id="#+id/btnBack"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:background="#drawable/back" />
<TextView
android:id="#+id/tvWarningNoEmp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="choose an employee from here to assign this problem to!"
android:textColor="#FF0000"
android:layout_marginLeft="400dp"
android:visibility="gone"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="40dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_weight="2"
android:background="#drawable/pepsiborder"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/blueborder"
android:orientation="horizontal"
android:padding="10dp" >
<ImageView
android:id="#+id/TicketIcon"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_gravity="center_vertical"
android:layout_weight="0.1" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="0.7"
android:gravity="center_vertical"
android:orientation="vertical" >
<TextView
android:id="#+id/ticketCat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="7dp"
android:gravity="center_vertical"
android:textColor="#D3D9FF"
android:textSize="17sp" />
</LinearLayout>
</LinearLayout>
<fragment
android:id="#+id/ticketMap"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp" />
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="State:"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#D3D9FF" />
<TextView
android:id="#+id/ticketState"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#D3D9FF" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ticket No:"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#D3D9FF" />
<TextView
android:id="#+id/ticketNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#D3D9FF" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Report Date:"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#D3D9FF" />
<TextView
android:id="#+id/ticketReportDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#D3D9FF" />
</LinearLayout>
<TextView
android:id="#+id/textView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Details:"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#D3D9FF" />
<TextView
android:id="#+id/ticketDetails"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#D3D9FF" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/llBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginBottom="10dp"
android:layout_marginTop="170dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#drawable/blueborder"
android:orientation="horizontal"
android:padding="10dp" >
<Button
android:id="#+id/btnTicketDirections"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_weight="1"
android:background="#drawable/directions" />
<Button
android:id="#+id/btnSolve"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_weight="1"
android:background="#drawable/solve" />
<Button
android:id="#+id/btnOther"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_weight="1"
android:background="#drawable/other" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/llListView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="40dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_weight="2"
android:background="#drawable/pepsiborder"
android:orientation="vertical" >
<TextView
android:id="#+id/textView124"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#D3D9FF"
android:text="Free Employees"
android:textSize="30sp"
android:gravity="left"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:textAppearance="?android:attr/textAppearanceLarge" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_marginLeft="20dp"
>
<ListView
android:id="#+id/listTic"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginRight="5dp"
android:layout_marginTop="20dp"
android:divider="#android:color/transparent"
android:dividerHeight="10dp" >
</ListView>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_weight="2"
android:id="#+id/noempLayout"
android:background="#android:color/transparent"
android:orientation="vertical" >
<TextView
android:text="Please select free Employee to handle this problem!"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:layout_marginTop="300dp"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="40dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_weight="2"
android:id="#+id/empLayout"
android:background="#drawable/pepsiborder"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/blueborder"
android:orientation="horizontal"
android:padding="10dp" >
<ImageView
android:id="#+id/empIcon"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_gravity="center_vertical"
android:layout_weight="0.1" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="0.7"
android:gravity="center_vertical"
android:orientation="vertical" >
<TextView
android:id="#+id/empName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="7dp"
android:gravity="center_vertical"
android:textColor="#D3D9FF"
android:textSize="17sp" />
</LinearLayout>
</LinearLayout>
<fragment
android:id="#+id/empMap"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView33"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Current Address:"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#D3D9FF" />
<TextView
android:id="#+id/empAddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#D3D9FF" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView22"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Details:"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#D3D9FF" />
<TextView
android:id="#+id/empDetails"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#D3D9FF" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/llBtn2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginTop="220dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#drawable/blueborder"
android:orientation="horizontal"
android:padding="10dp" >
<Button
android:id="#+id/btnEmpDirections"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_weight="1"
android:layout_gravity="center"
android:background="#drawable/directions" />
<Button
android:id="#+id/btnEmpChat"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_weight="1"
android:layout_gravity="center"
android:background="#drawable/chat" />
<Button
android:id="#+id/btnEmpAssign"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_weight="1"
android:layout_gravity="center"
android:background="#drawable/assign" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
ListView Item Layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="280dp"
android:layout_height="90dp"
android:orientation="horizontal"
android:background="#drawable/border"
android:layout_marginTop="10dp"
android:padding="10dp"
>
<ImageView
android:id="#+id/imgIcon"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_weight="0.1"
android:gravity="center_vertical"
/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="0.7"
android:gravity="center_vertical"
>
<TextView
android:id="#+id/txtTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:textSize="17sp"
android:textColor="#D3D9FF"
android:layout_gravity="center_vertical"
android:layout_marginLeft="7dp"
/>
<TextView
android:id="#+id/txtTitle1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_gravity="center_vertical"
android:textSize="13sp"
android:textColor="#D3D9FF"
android:layout_marginLeft="7dp"
/>
</LinearLayout>
</LinearLayout>
Border.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
>
<stroke
android:width="2dip"
android:color="#8D8D8D" />
<corners android:radius="10dip"/>
<solid android:color="#464A4F" />
</shape>
any help is truly appreciated.
If you want a view to blink:
public void blink(final View v) {
v.setBackgroundColor(Color.DKGRAY);
v.animate().setDuration(25).alpha(0).withEndAction(new Runnable() {
#Override
public void run() {
v.setBackgroundResource(R.drawable.standard_key_normal);
v.setAlpha(1);
}
});
}
Send your View to this function, replace the background with whatever drawable or color resource you want. If you want multiple blinks put it in a for loop.
well i figure out how to reduce the delay and add blink effect without using animation and some how it worked for me and there is no more delay, what i did is I've changed the list's linear layouts to relative and that reduced the amount of nested layouts significantly then i added this method:
private void blink(final View v){
final Handler handler = new Handler();
new Thread(new Runnable() {
#Override
public void run() {
int timeToBlink = 1000; //in milissegunds
try{Thread.sleep(timeToBlink);}catch (Exception e) {}
handler.post(new Runnable() {
#Override
public void run() {
if(v == View.VISIBLE){
v.setVisibility(View.INVISIBLE);
}else{
v.setVisibility(View.VISIBLE);
}
blink();
}
});
}
}).start();
then i used it inside onItemClickListener() --> blink(arg1);
worked perfectly for me, also getting the current address was taking too much so i used Async so now there is no delay at all:
Async used as an inner class:
private class LongOperation extends AsyncTask<String, Void, String> {
String all;
#Override
protected String doInBackground(String... params) {
// current address
Geocoder geocoder;
List<Address> addresses;
geocoder = new Geocoder(getApplicationContext(), Locale
.getDefault());
try {
addresses = geocoder.getFromLocation(empLatitude,
empLongitude, 1);
String street = addresses.get(0).getAddressLine(0);
String state = addresses.get(0).getAdminArea();
String country = addresses.get(0).getCountryName();
all="" + country + "-" + state
+ "-" + street + " st.";
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();}
return all;
}
#Override
protected void onPostExecute(String result) {
tvEmpCurrentAdd.setText(all);
}
#Override
protected void onPreExecute() {}
#Override
protected void onProgressUpdate(Void... values) {}
}
and then i called it inside onItemClickListener:
new LongOperation().execute();
hope this will help others that had simillar problem.

How to wrap Dialog Window to Content?

I'm developing a Dialog, which should shrink to its content, so, I want to get a behaviour like wrap_content in a common view but for a normal Dialog.
That's what I want to show in a Dialog Window
In a Dialog Window should look like this
but this is what I actually get
Could you say me what I do wrong?
I thank you in Advance.
That's my code
...
final Dialog dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.advanced_options);
dialog.setTitle(titleId);
// Stuff referred to builder
AlertDialog.Builder builder ...
...
int type = WindowManager.LayoutParams.TYPE_INPUT_METHOD;
WindowManager.LayoutParams w_layout_params = new WindowManager.LayoutParams(type);
dialog.getWindow().setAttributes(w_layout_params );
...
builder.create();
dialog.show();
advanced_options.xml Layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/relLayout_advancedOptions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#drawable/border_advanced_options"
android:divider="?android:listSeparatorTextViewStyle"
android:showDividers="" >
<TextView
android:id="#+id/speed_limit"
style="?android:attr/listSeparatorTextViewStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="20dp"
android:text="#string/speed_limit"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#color/black"
android:textSize="14dp" />
<TextView
android:id="#+id/speed_limit_alert"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/speed_limit"
android:layout_marginLeft="15dp"
android:layout_marginTop="20dp"
android:text="#string/speed_limit_alert"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/black" />
<TextView
android:id="#+id/percent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/speed_limit_alert"
android:layout_toRightOf="#+id/speed_limit_alert_edit_text"
android:text="#string/percentage_symbol"
android:textColor="#color/black" />
<TextView
android:id="#+id/minimum_speed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/speed_limit_alert"
android:layout_below="#+id/speed_limit_alert_edit_text"
android:layout_marginTop="15dp"
android:text="#string/minimum_speed"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/black" />
<EditText
android:id="#+id/minimum_speed_edit_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/minimum_speed"
android:layout_alignBottom="#+id/minimum_speed"
android:layout_alignLeft="#+id/speed_limit_alert_edit_text"
android:ems="3"
android:inputType="number"
android:textColor="#color/black"
android:text="6" />
<TextView
android:id="#+id/minimum_speed_unit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/minimum_speed"
android:layout_alignLeft="#+id/percent"
android:text="#string/metric_speed_unit"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/black" />
<TextView
android:id="#+id/maximum_speed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/minimum_speed"
android:layout_below="#+id/minimum_speed_edit_text"
android:layout_marginTop="15dp"
android:text="#string/maximum_speed"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/black"/>
<EditText
android:id="#+id/maximum_speed_edit_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/maximum_speed"
android:layout_alignBottom="#+id/maximum_speed"
android:layout_alignLeft="#+id/minimum_speed_edit_text"
android:ems="3"
android:inputType="number"
android:textColor="#color/black"
android:text="18" />
<TextView
android:id="#+id/maximum_speed_unit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/maximum_speed"
android:layout_toRightOf="#+id/maximum_speed_edit_text"
android:text="#string/metric_speed_unit"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/black"/>
<TextView
android:id="#+id/mobile_device_performance"
style="?android:attr/listSeparatorTextViewStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/maximum_speed_edit_text"
android:layout_marginTop="20dp"
android:gravity="center_vertical"
android:text="#string/mobile_device_performance"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#color/black"
android:textSize="14dp"
android:textStyle="bold" />
<TextView
android:id="#+id/maximum_number_objects"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/maximum_speed"
android:layout_below="#+id/mobile_device_performance"
android:layout_marginTop="20dp"
android:text="#string/maximum_objects_in_view"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/black" />
<EditText
android:id="#+id/maximum_number_objects_edit_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/maximum_number_objects"
android:layout_alignBottom="#+id/maximum_number_objects"
android:layout_marginLeft="10dp"
android:layout_toRightOf="#+id/maximum_number_objects"
android:ems="3"
android:inputType="number"
android:text="450"
android:textColor="#color/black" />
<EditText
android:id="#+id/speed_limit_alert_edit_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/percent"
android:layout_alignBottom="#+id/percent"
android:layout_alignLeft="#+id/maximum_number_objects_edit_text"
android:ems="3"
android:inputType="number"
android:text="42"
android:textColor="#color/black" >
<requestFocus />
</EditText>
<View
android:id="#+id/void_view"
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/maximum_speed_unit"
android:layout_below="#+id/maximum_number_objects" />
Change RelativeView's width to match_parent
What you're looking for is match_parent's behavior.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/relLayout_advancedOptions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#drawable/border_advanced_options"
android:divider="?android:listSeparatorTextViewStyle"
android:showDividers="" >
Note: wrap_content in android specifies the view to use as little space as needed and that is the behavior you're getting.
I could adjust the Dialog (NOT AlertDialog!) to my custom Layout but I couldn't* set either the Title or the Buttons so that I got an Exception cause of setting content before requestFeature, then I decided to custom my Dialog and including the Buttons and title in my Custom Layout.
*I have researched and it's possible to overcome that if we define the Dialog in OnCreate other even in OnCreateDialog but I have an extra Class just for static Dialog Methods and was no solution for me.
In Addition I post what it was useful for me, perhaps someone is also useful.
Now my custom dialog looks like this
Here the code for whom wants to test it.
/**
* #param c
* the Context
* #return the about dialog
*/
public static void getAdvancedOptions(final Activity activity) {
Log.i("TAG", "Dialogs::getAdvancedOptions:: 0");
//settings = session.getSettings();
// Creation of a Dialog with Frame and title Characteristics
final Dialog dialog = new Dialog(activity);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.advanced_options_expanded);
// Here we control the validity of "edit_text" Fields
speed_limit_alert = (EditText)dialog.findViewById(R.id.speed_limit_alert_edit_text);
minimum_speed = (EditText)dialog.findViewById(R.id.minimum_speed_edit_text);
maximum_speed = (EditText)dialog.findViewById(R.id.maximum_speed_edit_text);
max_objects_in_view = (EditText)dialog.findViewById(R.id.maximum_number_objects_edit_text);
//showAdvancedOptions("getAdvancedOptions 1::");
// First we set the "SharedPreferences"-saved values on EditText Fields
performEditText(speed_limit_alert,Constants.MIN_PERCENTAGE, Constants.MAX_PERCENTAGE,"speed_limit_alert");
performEditText(minimum_speed, "","", "minimum_speed");
performEditText(maximum_speed, "","","maximum_speed");
performEditText(max_objects_in_view, "","","max_objects_in_view");
//showAdvancedOptions("getAdvancedOptions 4::");
ok_button = (Button)dialog.findViewById(R.id.ok_button);
cancel_button = (Button)dialog.findViewById(R.id.cancel_button);
// Definition of "OK" Button for the Dialog
ok_button.setOnClickListener(new OnClickListener(){
#Override
public void onClick(View v) {
Log.i("TAG", "Dialogs::getAdvancedOptions::onClick");
if ( dialog != null && dialog.isShowing()) {
dialog.dismiss();
}
}
});
cancel_button.setOnClickListener(new OnClickListener(){
#Override
public void onClick(View v) {
Log.i("TAG", "Dialogs::getAdvancedOptions::onClick");
if ( dialog != null && dialog.isShowing()) {
dialog.dismiss();
}
}
});
dialog.show();
}
private static void performEditText(EditText edit_text, final String min_value, final String max_value, final String id) {
String edit_text_value = edit_text.getText().toString();
Log.i("TAG", "Dialogs::performEditText:: id: "+ id +" edit_text_value: "+edit_text_value+ " (min_value,max_value)=("+min_value+","+max_value+")");
TextWatcher textWatcher = new TextWatcher() {
public void afterTextChanged(Editable s) {
int i = 0;
Log.i("TAG","Dialogs::performEditText::afterTextChanged:id: "+ id +" - 0 : s: "+s.toString());
int length = s.length();
if ( length == 0 )
i = 0;
else if ( length < 3 ) {
if ( s.charAt(0) == '0')
s.delete(1, length );
i = Integer.parseInt(s.toString());
Log.i("TAG","Dialogs::performEditText::afterTextChanged:id: "+ id +" - 1a : s: "+s+", i:"+i);
} else {
//String hundred = "100";
String s_value = s.toString();
Log.i("TAG","Dialogs::performEditText::afterTextChanged: id: "+ id +" - 1b : s: "+s+", i:"+i);
if ( ( min_value != null ) && ( min_value.length() != 0 ) && ( max_value != null) && ( max_value.length() != 0 )) {
if ( !s_value.equalsIgnoreCase(max_value))
s.delete(2, length );
}
i = Integer.parseInt(s.toString());
Log.i("TAG","Dialogs::performEditText::afterTextChanged: id: "+ id +" - 2b : i: "+i);
}
if (i >= 0 && i <= 100) {
Log.i("TAG","Dialogs::performEditText::afterTextChanged: id: "+ id +" - 3 : (i >= 0 && i <= 100): i: "+i);
//speed_limit_alert.setText(s); // This ensures 0-100 value for speed_limit_alert
}
Log.i("TAG","Dialogs::performEditText::afterTextChanged: id: "+ id +" - 4 : i: "+i);
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
Log.i("TAG","Dialogs::performEditText::beforeTextChanged: id: "+ id +" s: "+s);
}
public void onTextChanged(CharSequence s, int start, int before, int count) {
Log.i("TAG","Dialogs::performEditText::onTextChanged: id: "+ id +" s: "+s);
}
};
edit_text.addTextChangedListener(textWatcher);
}
private static void showAdvancedOptions(String entryPoint) {
String s_l_a = speed_limit_alert.getText().toString();
Log.i("TAG", entryPoint + "Dialogs::setAdvancedOptions:: s_l_a: "+s_l_a);
String mi_s = minimum_speed.getText().toString();
Log.i("TAG", entryPoint + "Dialogs::setAdvancedOptions:: mi_s: "+mi_s);
String ma_s = maximum_speed.getText().toString();
Log.i("TAG", entryPoint + "Dialogs::setAdvancedOptions:: ma_s: "+ma_s);
String m_o_i_v = max_objects_in_view.getText().toString();
Log.i("TAG", entryPoint + "Dialogs::setAdvancedOptions:: m_o_i_v: "+m_o_i_v);
}
And the layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#drawable/border_advanced_options"
android:divider="?android:listSeparatorTextViewStyle"
android:showDividers="middle" >
<RelativeLayout
android:id="#+id/relLayout_advancedOptions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/white"
android:divider="?android:listSeparatorTextViewStyle"
android:orientation="vertical"
android:showDividers="" >
<TextView
android:id="#+id/speed_limit"
style="?android:attr/listSeparatorTextViewStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/void_view_0"
android:layout_marginTop="10dp"
android:text="#string/speed_limit"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#color/black"
android:textSize="14dp" />
<TextView
android:id="#+id/speed_limit_alert"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/speed_limit"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:text="#string/speed_limit_alert"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/black" />
<TextView
android:id="#+id/percent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/speed_limit_alert"
android:layout_toRightOf="#+id/speed_limit_alert_edit_text"
android:text="#string/percentage_symbol"
android:textColor="#color/black" />
<TextView
android:id="#+id/minimum_speed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/speed_limit_alert"
android:layout_below="#+id/speed_limit_alert_edit_text"
android:layout_marginTop="15dp"
android:text="#string/minimum_speed"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/black" />
<EditText
android:id="#+id/minimum_speed_edit_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/minimum_speed"
android:layout_alignBottom="#+id/minimum_speed"
android:layout_alignLeft="#+id/speed_limit_alert_edit_text"
android:ems="3"
android:inputType="number"
android:text="6"
android:textColor="#color/black" />
<TextView
android:id="#+id/minimum_speed_unit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/minimum_speed"
android:layout_alignLeft="#+id/percent"
android:paddingRight="5dp"
android:text="#string/metric_speed_unit"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/black" />
<TextView
android:id="#+id/maximum_speed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/minimum_speed"
android:layout_below="#+id/minimum_speed_edit_text"
android:layout_marginTop="15dp"
android:text="#string/maximum_speed"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/black" />
<EditText
android:id="#+id/maximum_speed_edit_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/maximum_speed"
android:layout_alignBottom="#+id/maximum_speed"
android:layout_alignLeft="#+id/minimum_speed_edit_text"
android:ems="3"
android:inputType="number"
android:text="18"
android:textColor="#color/black" />
<TextView
android:id="#+id/maximum_speed_unit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/maximum_speed"
android:layout_alignRight="#+id/minimum_speed_unit"
android:layout_toRightOf="#+id/maximum_speed_edit_text"
android:paddingRight="5dp"
android:text="#string/metric_speed_unit"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/black" />
<TextView
android:id="#+id/mobile_device_performance"
style="?android:attr/listSeparatorTextViewStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/maximum_speed_edit_text"
android:layout_marginTop="20dp"
android:gravity="center_vertical"
android:text="#string/mobile_device_performance"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#color/black"
android:textSize="14dp"
android:textStyle="bold" />
<TextView
android:id="#+id/maximum_number_objects"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/maximum_speed"
android:layout_below="#+id/mobile_device_performance"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:text="#string/maximum_objects_in_view"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/black" />
<EditText
android:id="#+id/maximum_number_objects_edit_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/maximum_number_objects"
android:layout_alignBottom="#+id/maximum_number_objects"
android:layout_marginLeft="10dp"
android:layout_toRightOf="#+id/maximum_number_objects"
android:ems="3"
android:inputType="number"
android:text="450"
android:textColor="#color/black" />
<EditText
android:id="#+id/speed_limit_alert_edit_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/percent"
android:layout_alignBottom="#+id/percent"
android:layout_alignLeft="#+id/maximum_number_objects_edit_text"
android:digits="0123456789"
android:ems="3"
android:inputType="number"
android:text="42"
android:textColor="#color/black" >
<requestFocus />
</EditText>
<View
android:id="#+id/void_view"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/lin_layout_buttons"
android:layout_below="#+id/maximum_number_objects"
android:background="#color/black" />
<TextView
android:id="#+id/title_advanced_options"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignRight="#+id/minimum_speed_unit"
android:drawableLeft="#drawable/ic_launcher_48"
android:drawableRight="#drawable/ic_action_settings_48"
android:gravity="center|center_vertical"
android:paddingLeft="5dp"
android:text="Advanced Options"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#color/blue" />
<View
android:id="#+id/void_view_0"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/title_advanced_options"
android:layout_below="#+id/title_advanced_options"
android:background="#color/black" />
<LinearLayout
android:id="#+id/lin_layout_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/minimum_speed_unit"
android:layout_alignTop="#+id/void_view"
android:weightSum="3" >
<Button
android:id="#+id/ok_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/maximum_number_objects"
android:layout_alignRight="#+id/speed_limit_alert"
android:layout_below="#+id/maximum_number_objects_edit_text"
android:layout_weight="1.5"
android:text="OK" />
<Button
android:id="#+id/cancel_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/button1"
android:layout_alignBottom="#+id/button1"
android:layout_toRightOf="#+id/button1"
android:layout_weight="1.5"
android:text="Cancel" />
</LinearLayout>
</RelativeLayout>

java.lang.NumberFormatException is there a better way around this issure?

Here is my Java file for my app that I am working on. The in logcat it is saying there is an error in the initvar() method in this line "length1et = (EditText) findViewById(R.id.etlength1);" I know this is because there is not a variable in the edittext box and I have had this problem before and just put 0's there to start out. Is there a simple command to have nothing there and it will just understand to automatically put in a 0 for the value or is the only way to write some code to treat it as a zero? Below the java code is the xml if that is necessary. In a previous app I have just had it read the edittext box and if nothing is there, set the value to 0 before it does anything else. For the record I know I don't have a button to call the calculate() method I just haven't put that in yet.
package com.example.constructioncalculator;
import android.app.Activity;
import android.os.Bundle;
import android.widget.EditText;
public class Paint extends Activity {
int numwin, numdoor;
double areadoor, areawin, lengthft, lengthin, widthft, widthin, heightft,
heightin, areawall, areaceil, paintcon, paintneeded;
EditText length1et, length2et, width1et, width2et, height1et, height2et,
paintconet, paintneededet;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.paintdisp);
initvar();
calculate();
output();
}
private void initvar() {
// TODO Auto-generated method stub
numwin = 0;
numdoor = 0;
areawin = 20;
areadoor = 19.5;
lengthft = 0;
lengthin = 0;
widthft = 0;
widthin = 0;
heightft = 0;
heightin = 0;
areawall = 0;
areaceil = 0;
paintcon = 0;
paintneeded = 0;
length1et = (EditText) findViewById(R.id.etlength1);
length2et = (EditText) findViewById(R.id.etlength2);
width1et = (EditText) findViewById(R.id.etwidth1);
width2et = (EditText) findViewById(R.id.etwidth2);
height1et = (EditText) findViewById(R.id.etheight1);
height2et = (EditText) findViewById(R.id.etheight2);
paintconet = (EditText) findViewById(R.id.etpaintcon);
paintneededet = (EditText) findViewById(R.id.etpaintneeded);
}
private void calculate() {
// TODO Auto-generated method stub
lengthft = Double.parseDouble(length1et.getText().toString());
lengthin = Double.parseDouble(length2et.getText().toString());
widthft = Double.parseDouble(width1et.getText().toString());
widthin = Double.parseDouble(width2et.getText().toString());
heightft = Double.parseDouble(height1et.getText().toString());
heightin = Double.parseDouble(height2et.getText().toString());
paintcon = Double.parseDouble(paintconet.getText().toString());
areaceil = (lengthft + lengthin / 12) * (widthft + widthin / 12);
areawall = areaceil * (heightft + heightin / 12) - (numwin * areawin)
- (numdoor * areadoor);
paintneeded = (areawall / paintcon) * 1.1;
}
private void output() {
// TODO Auto-generated method stub
paintneededet.setText(String.valueOf(paintneeded));
}
}
*********Here is my xml file...
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/TextView04"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Paint Coverage Estimator"
android:textSize="30dp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:text="#string/paintinst" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/tvlength"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Length"
android:textSize="20dp" />
<TextView
android:id="#+id/tvwidth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Width"
android:textSize="20dp" />
<TextView
android:id="#+id/tvheight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Height"
android:textSize="20dp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/etlength1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:hint="feet"
android:text="1"
android:textSize="10dp" />
<EditText
android:id="#+id/etlength2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:hint="inches"
android:text="1"
android:textSize="10dp" />
<EditText
android:id="#+id/etwidth1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:hint="feet"
android:text="1"
android:textSize="10dp" />
<EditText
android:id="#+id/etwidth2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:hint="inches"
android:text="1"
android:textSize="10dp" />
<EditText
android:id="#+id/etheight1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:hint="feet"
android:text="1"
android:textSize="10dp" />
<EditText
android:id="#+id/etheight2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:hint="inches"
android:text="1"
android:textSize="10dp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="approx paint coverage (ft^2)?" />
<EditText
android:id="#+id/etpaintcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="300" >
<requestFocus />
</EditText>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/editText3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Paint needed of your buckets" />
<EditText
android:id="#+id/etpaintneeded"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Try this:
lengthft = Double.parseDouble(length1et.getText().toString()+0);
But be aware, if the user type in a invalid number and click on the button you haven't implemented yet, your app will crash. So you should probably add a check to all the EditText's before you call calculate().
Or even better, add a function to do it for you:
lengthft = getDouble(length1et);
public double getDouble(EditText et) {
if (!et.getText().equals(null)) {
return Double.parseDouble(et.getText().toString()); //convert your string into integer
} else {
return 0; // or what you want to return if string is Null
}
}

Android View Animation

i've been scrounging the internet for a while now and have been unable to find s viable solution for my animation problem.
I have a list view where when you click on one of the items, more information animates from the bottom to give you a few lines of additional information. That is simply a linearlayout that i have inside the XML file im using for these list items, here:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:id="#+id/friendActivityList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/friendInfo"
android:background="#color/grey"
android:orientation="vertical"
android:visibility="gone" >
<RelativeLayout
android:id="#+id/RelativeLayout04"
android:layout_width="match_parent"
android:layout_height="#dimen/freind_activity_list_height" >
<ImageView
android:id="#+id/ImageView04"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_margin="5dp"
android:src="#drawable/logo_d" />
<TextView
android:id="#+id/TextView04"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="#+id/ImageView04"
android:text="TextView"
android:textColor="#color/black"
android:textSize="17dp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/RelativeLayout03"
android:layout_width="match_parent"
android:layout_height="#dimen/freind_activity_list_height" >
<ImageView
android:id="#+id/ImageView03"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_margin="5dp"
android:src="#drawable/logo_d" />
<TextView
android:id="#+id/TextView03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="#+id/ImageView03"
android:text="TextView"
android:textColor="#color/black"
android:textSize="17dp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/RelativeLayout02"
android:layout_width="match_parent"
android:layout_height="#dimen/freind_activity_list_height" >
<ImageView
android:id="#+id/ImageView02"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_margin="5dp"
android:src="#drawable/logo_d" />
<TextView
android:id="#+id/TextView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="#+id/ImageView02"
android:text="TextView"
android:textColor="#color/black"
android:textSize="17dp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="#dimen/freind_activity_list_height" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_margin="5dp"
android:src="#drawable/logo_d" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="#id/imageView1"
android:text="TextView"
android:textColor="#color/black"
android:textSize="17dp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/RelativeLayout01"
android:layout_width="match_parent"
android:layout_height="#dimen/freind_activity_list_height">
<ImageView
android:id="#+id/ImageView01"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_margin="5dp"
android:src="#drawable/logo_d" />
<TextView
android:id="#+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="#+id/ImageView01"
android:text="TextView"
android:textColor="#color/black"
android:textSize="17dp" />
</RelativeLayout>
</LinearLayout>
<RelativeLayout
android:id="#+id/friendInfo"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:background="#drawable/bg_list_item_n" >
<ImageView android:id="#+id/imgCompany"
android:layout_marginLeft="5dp"
android:layout_centerVertical="true"
android:layout_width="60dp"
android:src="#drawable/ic_launcher"
android:scaleType="centerInside"
android:layout_alignParentLeft="true"
android:layout_height="50dp">
</ImageView>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="60dp"
android:layout_toRightOf="#id/imgCompany"
android:background="#android:color/transparent"
android:gravity="left|center"
android:orientation="vertical"
android:paddingLeft="5dp" >
<TextView android:id="#+id/lblCompanyName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/white"
android:textStyle="bold"
android:textSize="13dp"
android:text="Company Name">
</TextView>
<TextView android:id="#+id/lblReawrdDesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/white"
android:textSize="13dp"
android:text="Reawrd Description">
</TextView>
<TextView android:id="#+id/lblScores"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/white"
android:textSize="13dp"
android:singleLine="true"
android:text="My Score: 13434 | Top Score: 344425">
</TextView>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
Most of this is just place holder information so that i can get the animation to work correctly. Here is the code that im using for the animation:
listviewFriends.setOnItemClickListener(new OnItemClickListener() {//this is the listView that im animating inside of
public void onItemClick(AdapterView<?> parent, View view,final int pos, long id) {
Log.v("ListItemClicked", "this position was clicked: "+pos);
if(friendInfoList != null){
friendInfoList.clearAnimation();//this is the new view that gets animated and is supposed to push everything below it out of the way
friendInfoList.setVisibility(View.GONE);
}
friendInfoList = (LinearLayout) view.findViewById(R.id.friendActivityList);
friendInfoList.setVisibility(View.VISIBLE);
friendInfoList.startAnimation(infoAnim);
}
});
infoAnim = new TranslateAnimation(0,0, -150, 0);//this is the animation im using
infoAnim.setDuration(1000);
infoAnim.setFillAfter(true);
No the result of this is that when i click on the list view item the entire space that the supposed-to-be-animated view takes up at the end is white while the view animates from the top down. The location is correct, but i want it to animate and push everything below it out of the way, instead it instantly pushes everything out of the way then animates to fill that space.
Any idea how i can get it to push everything out of the way during the animation instead of immediately? Is it even possible to achieve this effect? any help is greatly appreciated.
Also, I know how i can make it simply animate ontop of the other views, but i need it to actually push everything out of the way.
The trick with this is to create your own Animation subclass.
public class ExpandAnimation extends Animation
{
private int _targetHeight;
private View _view;
private boolean _down;
public ExpandAnimation(View view, int targetHeight)
{
_view = view;
_targetHeight = targetHeight;
}
#Override
protected void applyTransformation(float interpolatedTime, Transformation t)
{
int newHeight;
if(_down)
{
newHeight = (int) (_targetHeight * interpolatedTime);
}
else
{
newHeight = (int) (_targetHeight * (1 - interpolatedTime));
}
_view.getLayoutParams().height = newHeight;
_view.requestLayout();
}
public ExpandAnimation expand()
{
_down = true;
return this;
}
public ExpandAnimation collapse()
{
_down = false;
return this;
}
#Override
public void initialize(int width, int height, int parentWidth, int parentHeight)
{
super.initialize(width, height, parentWidth, parentHeight);
}
#Override
public boolean willChangeBounds()
{
return true;
}
}
Then you can apply that to your view that should expand:
public void togglePreview()
{
if(_expanded) _preview.startAnimation(_animation.collapse());
else _preview.startAnimation(_animation.expand());
_expanded = !_expanded;
getParent().requestLayout();
}

Categories

Resources