How to make an own time table in android studio - java

I'm setting up my own time table and I have a lot of button on that I want to get multi-button I mean if someone wants to use the application. they can choose any time they want to have no limit. so how can I make a time table with those options?
here its XML file:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="370dp"
android:layout_height="480dp"
android:background="#00555555"
android:orientation="vertical"
android:padding="5dp"
android:weightSum="100">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/round_layout_otp"
android:orientation="vertical"
android:padding="7dp"
android:weightSum="100">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="166dp"
android:layout_weight="60"
android:orientation="horizontal"
android:weightSum="100">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="80"
android:gravity="center">
<ImageView
android:id="#+id/a"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#fff"
android:gravity="center"
android:scaleType="fitCenter"
android:src="#drawable/logo" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="20">
<TextView
android:id="#+id/txt_file_path"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:singleLine="true"
android:text="TEXTO"
android:textColor="#FFFFFF"
android:textSize="17sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="457dp"
android:layout_weight="40"
android:background="#drawable/round_layout_white_otp"
android:orientation="vertical"
android:weightSum="100">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_weight="0">
<TextView
android:layout_width="match_parent"
android:layout_height="36dp"
android:gravity="center"
android:text="Chose Your Time :"
android:textColor="#ff000000"
android:textSize="15dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="769dp"
android:layout_gravity="center"
android:layout_weight="60">
<ScrollView android:id="#+id/layout"
android:layout_height="match_parent"
android:scrollbars="horizontal|vertical"
android:layout_width="match_parent"
android:layout_marginTop="5dip"
android:scrollbarStyle="outsideInset"
android:fillViewport="true"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:layout_width="match_parent" android:orientation="vertical"
android:layout_height="match_parent">
<TableRow
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="75dp">
<Button android:layout_weight="1" android:text="8:00" android:layout_width="match_parent" android:layout_height="match_parent" android:textSize="13sp" android:id="#+id/bt1" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="8:15" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt2" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="8:30" android:layout_width="match_parent" android:layout_height="match_parent" android:textSize="13sp" android:id="#+id/bt3" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="8:45" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt4" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="9:00" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt5" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="9:15" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt6" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
</TableRow>
<TableRow
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="75dp">
<Button android:layout_weight="1" android:text="9:30" android:layout_width="match_parent" android:layout_height="match_parent" android:textSize="13sp" android:id="#+id/bt7" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="9:45" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt8" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="10:00" android:layout_width="match_parent" android:layout_height="match_parent" android:textSize="13sp" android:id="#+id/bt9" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="10:15" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt10" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="10:30" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt11" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="10:45" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt12" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
</TableRow>
<TableRow
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="75dp">
<Button android:layout_weight="1" android:text="11:00" android:layout_width="match_parent" android:layout_height="match_parent" android:textSize="13sp" android:id="#+id/bt13" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="11:15" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt14" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="11:30" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt15" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:id="#+id/bt16" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:text="11:45" android:textSize="13sp" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="12:00" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt17" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="12:15" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt18" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
</TableRow>
<TableRow
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="75dp">
<Button android:layout_weight="1" android:text="12:30" android:layout_width="match_parent" android:layout_height="match_parent" android:textSize="13sp" android:id="#+id/bt19" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="12:45" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt20" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="13:00" android:layout_width="match_parent" android:layout_height="match_parent" android:textSize="13sp" android:id="#+id/bt21" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="13:15" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt22" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="13:30" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt23" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="13:45" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt24" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
</TableRow>
<TableRow
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="75dp">
<Button android:layout_weight="1" android:text="14:00" android:layout_width="match_parent" android:layout_height="match_parent" android:textSize="13sp" android:id="#+id/bt25" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="14:15" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt26" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="14:30" android:layout_width="match_parent" android:layout_height="match_parent" android:textSize="13sp" android:id="#+id/bt27" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="14:45" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt28" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="15:00" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt29" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="15:15" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt30" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
</TableRow>
<TableRow
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="75dp">
<Button android:layout_weight="1" android:text="15:30" android:layout_width="match_parent" android:layout_height="match_parent" android:textSize="13sp" android:id="#+id/bt31" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="15:45" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt32" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="16:00" android:layout_width="match_parent" android:layout_height="match_parent" android:textSize="13sp" android:id="#+id/b33" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="16:15" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt34" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="16:30" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt35" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="16:45" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt36" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
</TableRow>
<TableRow
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="75dp">
<Button android:layout_weight="1" android:text="17:00" android:layout_width="match_parent" android:layout_height="match_parent" android:textSize="13sp" android:id="#+id/bt37" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="17:15" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt38" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="17:30" android:layout_width="match_parent" android:layout_height="match_parent" android:textSize="13sp" android:id="#+id/bt39" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="17:45" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt40" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="18:00" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt41" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="18:15" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt42" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
</TableRow>
<TableRow
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="75dp">
<Button android:layout_weight="1" android:text="18:30" android:layout_width="match_parent" android:layout_height="match_parent" android:textSize="13sp" android:id="#+id/bt43" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="18:45" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt44" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="19:00" android:layout_width="match_parent" android:layout_height="match_parent" android:textSize="13sp" android:id="#+id/bt45" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="19:15" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt46" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="19:30" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt47" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="19:45" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt48" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
</TableRow>
</LinearLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="350dp"
android:layout_weight="40"
android:orientation="horizontal"
android:weightSum="0">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginRight="30dp"
android:layout_weight="50"
android:gravity="center|right">
<Button
android:id="#+id/btn_cancel"
android:layout_width="80dp"
android:layout_height="25dp"
android:background="#drawable/round_button"
android:gravity="center"
android:text="CANCEL"
android:textColor="#ffffffff"
android:textSize="13dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="30dp"
android:layout_weight="50"
android:gravity="center|left">
<Button
android:id="#+id/btn_okay"
android:layout_width="80dp"
android:layout_height="25dp"
android:background="#drawable/round_button"
android:text="OKAY"
android:textColor="#ffffffff"
android:textSize="13dp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
here activity code :
public class ViewDialog extends AppCompatActivity {
private int buttonState = 2;
ArrayList<String> al = new ArrayList<String>();
public void showDialog(Activity activity, String msg) {
final Dialog dialog = new Dialog(activity);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setCancelable(false);
dialog.setContentView(R.layout.time_dialog);
dialog.getWindow().setBackgroundDrawable(new
ColorDrawable(android.graphics.Color.TRANSPARENT));
TextView text = (TextView) dialog.findViewById(R.id.txt_file_path);
text.setText(msg);
Button bt1 = (Button) dialog.findViewById(R.id.bt1);
bt1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if(buttonState % 2 == 0){
bt1.setBackgroundColor(dialog.getContext().getColor(R.color.btnclick));
al.add(bt1.getText().toString());
}
else{
bt1.setBackgroundColor(dialog.getContext().getColor(R.color.colorAccent));
al.remove(bt1.getText().toString());
}
buttonState++;
}
});
Button dialogBtn_cancel = (Button)
dialog.findViewById(R.id.btn_cancel);
dialogBtn_cancel.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
//
Toast.makeText(getApplicationContext(),"Cancel" ,Toast.LENGTH_SHORT).show();
dialog.dismiss();
}
});
Button dialogBtn_okay = (Button) dialog.findViewById(R.id.btn_okay);
dialogBtn_okay.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Toast.makeText(dialog.getContext(),al.get(0),Toast.LENGTH_SHORT).show();
dialog.cancel();
}
});
dialog.show();
}
}
public class ViewDialog extends AppCompatActivity {
private int buttonState = 2;
ArrayList<String> al = new ArrayList<String>();
public void showDialog(Activity activity, String msg) {
final Dialog dialog = new Dialog(activity);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setCancelable(false);
dialog.setContentView(R.layout.time_dialog);
dialog.getWindow().setBackgroundDrawable(new
ColorDrawable(android.graphics.Color.TRANSPARENT));
TextView text = (TextView) dialog.findViewById(R.id.txt_file_path);
text.setText(msg);
Button bt1 = (Button) dialog.findViewById(R.id.bt1);
bt1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if(buttonState % 1 == 0){
bt1.setBackgroundColor(dialog.getContext().getColor(R.color.btnclick));
al.add(bt1.getText().toString());
}
else{
bt1.setBackgroundColor(dialog.getContext().getColor(R.color.colorAccent));
al.remove(bt1.getText().toString());
}
buttonState++;
}
});
Button dialogBtn_cancel = (Button)
dialog.findViewById(R.id.btn_cancel);
dialogBtn_cancel.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
//
Toast.makeText(getApplicationContext(),"Cancel" ,Toast.LENGTH_SHORT).show();
dialog.dismiss();
}
});
Button dialogBtn_okay = (Button) dialog.findViewById(R.id.btn_okay);
dialogBtn_okay.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Toast.makeText(dialog.getContext(),al.get(0),Toast.LENGTH_SHORT).show();
dialog.cancel();
}
});
dialog.show();
}
}
And also I need a variable for the selected time. please help me
Question 1: how to make a multi-button?
Question 2: how to make a variable for the selected time?

Related

Play several mp3 files in one Onclick statement?

I'm learning android and my first app is a simple music instrument. I have 7 buttons at the moment, and i'm using MediaPlayer for each one. The thing is that every button has the same functionality, and I want to avoid a switch statement on the Onclick method - wich is the only thing i find on the web. Someone told me to name the buttons with the correspondent mp3 file and write a simple "play" function that would match the right key/button, but I guess i'm not doing it right. Can someone help me out? Here's what i've got, and much apreciated for the help:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
//these buttons have the same name as the mp3 key notes file
c1= (Button) findViewById(R.id.key1);
c1.setOnClickListener(this);
d1= (Button) findViewById(R.id.key2);
d1.setOnClickListener(this);
e1= (Button) findViewById(R.id.key3);
e1.setOnClickListener(this);
f1= (Button) findViewById(R.id.key4);
f1.setOnClickListener(this);
g1= (Button) findViewById(R.id.key5);
g1.setOnClickListener(this);
a1=(Button) findViewById(R.id.key6);
a1.setOnClickListener(this);
b1=(Button) findViewById(R.id.key7);
b1.setOnClickListener(this);
The OnClick method (the first if example works, of course, but if I want a complex instrument I'll have repeated code. So I want this "else" to be the only statement):
#Override
public void onClick(View v) {
Button b = (Button)v;
String note=b.getText().toString();
if(v==c1){
mp = MediaPlayer.create(this, R.raw.c1);
mp.start();
}
else{
play( note+".mp3");
}
And the attempt of the play method:
public void play(String note){
note.equals("cs2");//??
//the mp3 files are stored in res/raw and I also tried that specific path but it didnt work. The keys are silent, except the c1
}
EDIT:
Now I have only this:
public void play(String note){
mp = MediaPlayer.create(this,getResources().getIdentifier(note,"raw",getPackageName()));
mp.start();
}
#Override
public void onClick(View v) {
clickCount++;
updateClickCount();
Button b = (Button)v;
String note=b.getText().toString();
play(note);
}
But the app still crashes
EDIT: The XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_main2"
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"
tools:context="com.example.vtorferreira.sounds.MainActivity">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_main"
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"
tools:context="com.example.vtorferreira.sounds.MainActivity">
<ImageView
android:layout_width="300dp"
android:layout_height="1200dp"
android:id="#+id/kid"
android:src="#drawable/kid"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:clickable="true"/>
<ImageView
android:layout_width="300dp"
android:layout_height="1200dp"
android:id="#+id/partido"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:clickable="true"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="10">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="5"
android:orientation="horizontal"
android:weightSum="34"
android:gravity="center">
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#9BC53D"
android:visibility="invisible"
android:id="#+id/key1_ext"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:layout_marginLeft="1dp"
android:layout_marginRight="1dp"
android:background="#000000"
android:visibility="invisible"
android:id="#+id/black1"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#2660A4"
android:visibility="invisible"
android:id="#+id/key2_ext"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#000000"
android:visibility="invisible"
android:id="#+id/black2"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#399E5A"
android:visibility="invisible"
android:id="#+id/key3_ext"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#5F0F40"
android:visibility="invisible"
android:id="#+id/key4_ext"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#000000"
android:visibility="invisible"
android:id="#+id/black3"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#FA7921"
android:visibility="invisible"
android:id="#+id/key5_ext"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#000000"
android:visibility="invisible"
android:id="#+id/black4"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#9BC53D"
android:visibility="invisible"
android:id="#+id/key6_ext"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#000000"
android:visibility="invisible"
android:id="#+id/black5"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#2660A4"
android:visibility="invisible"
android:id="#+id/key7_ext"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#399E5A"
android:visibility="invisible"
android:id="#+id/key8_ext"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#000000"
android:visibility="invisible"
android:id="#+id/black6"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#5F0F40"
android:visibility="invisible"
android:id="#+id/key9_ext"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#000000"
android:visibility="invisible"
android:id="#+id/black7"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#FA7921"
android:visibility="invisible"
android:id="#+id/key10_ext"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#000000"
android:visibility="invisible"
android:id="#+id/black8"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#9BC53D"
android:visibility="invisible"
android:id="#+id/key11_ext"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#2660A4"
android:visibility="invisible"
android:id="#+id/key12_ext"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#000000"
android:visibility="invisible"
android:id="#+id/black9"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#399E5A"
android:visibility="invisible"
android:id="#+id/key13_ext"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#000000"
android:visibility="invisible"
android:id="#+id/black10"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#5F0F40"
android:visibility="invisible"
android:id="#+id/key14_ext"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="10"
android:orientation="horizontal"
android:weightSum="7"
android:gravity="center">
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#2660A4"
android:visibility="invisible"
android:id="#+id/key1"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#2660A4"
android:visibility="invisible"
android:id="#+id/key2"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#399E5A"
android:visibility="invisible"
android:id="#+id/key3"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#5F0F40"
android:visibility="invisible"
android:id="#+id/key4"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#FA7921"
android:visibility="invisible"
android:id="#+id/key5"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#9BC53D"
android:visibility="invisible"
android:id="#+id/key6"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#2660A4"
android:visibility="invisible"
android:id="#+id/key7"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#399E5A"
android:visibility="invisible"
android:id="#+id/key8"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#5F0F40"
android:visibility="invisible"
android:id="#+id/key9"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#FA7921"
android:visibility="invisible"
android:id="#+id/key10"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#9BC53D"
android:visibility="invisible"
android:id="#+id/key11"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#2660A4"
android:visibility="invisible"
android:id="#+id/key12"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#399E5A"
android:visibility="invisible"
android:id="#+id/key13"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#5F0F40"
android:visibility="invisible"
android:id="#+id/key14"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="6"
android:orientation="horizontal"
android:weightSum="10"
android:gravity="center">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:id="#+id/pontos"
android:textSize="15sp"
android:textStyle="normal|bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:orientation="horizontal"
android:weightSum="8"
android:gravity="center">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:orientation="horizontal"
android:gravity="center">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:background="#2072CA"
android:id="#+id/pref"
android:text="Preferences"
/>
<ToggleButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:background="#2072CA"
android:id="#+id/solo"
android:textOff="Play Magic Piano!"
android:textOn="Close Piano"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:background="#2072CA"
android:id="#+id/learn"
android:text="Learn about piano"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
Remove file extension (+ ".mp3") and use :
getResources().getIdentifier("FILE NAME WITHOUT EXTENSION","raw", getPackageName())
Also make sure each of your button text is holding a filename present in your raw folder without extension. For exemple "c1".
Here is how should look final code :
#Override
public void onClick(View v) {
Button b = (Button)v;
String note = b.getText().toString().toLowerCase();
play(note);
}
public void play(String note){
try {
mp = MediaPlayer.create(this,getResources().getIdentifier(note,"raw", getPackageName()));
mp.start();
} catch (Exception e) {
Log.e("Error", "error playing file with name : " + note + "\n" + e);
}
}
You must set text on your buttons elements. For each one, you should display a filename. for example adding android:text"c1" :
<Button
android:text="c1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#2660A4"
android:visibility="visible"
android:id="#+id/key1"/>
To clarify a bit, the code retrieve the text on the button. for example 'c1'. Then, your app will try to find the file with name c1 in your raw folder. If you don't set any text on your buttons... Then of course, your app won't find any resource with name '' ! Hope you understand what I mean.

how to display all items in the listview

I'm trying to include a ListView on a screen that already exists in my app.
My problem is that the ListView is displaying only the first item. I wish it were
displayed all the list.
Here is the my screen's xml:
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/radialback"
android:orientation="vertical">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:isScrollContainer="true"
android:orientation="vertical"
android:shrinkColumns="*">
<TableLayout
android:id="#id/tabela_cuerpo"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="0">
<TableRow
android:id="#id/tableRow0"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="#id/textView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:background="#drawable/tabela_cabecalho"
android:gravity="center_horizontal"
android:text="Corrida Recebida"
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ff000000"
android:textStyle="bold"/>
</TableRow>
<TableRow
android:id="#id/tableRow1"
android:layout_height="fill_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:background="#drawable/tabela_conteudo"
android:paddingLeft="3.0dip"
android:text="Cliente: "
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ff000000"
android:textStyle="bold"/>
<TextView
android:id="#id/txtPassageiro"
android:layout_height="fill_parent"
android:layout_weight="2.0"
android:background="#drawable/tabela_conteudo"
android:paddingLeft="3.0dip"
android:text=""
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ff000000"/>
</TableRow>
<TableRow
android:id="#id/tableRow2"
android:layout_height="fill_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:background="#drawable/tabela_conteudo"
android:paddingLeft="3.0dip"
android:text="Distância: "
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ff000000"
android:textStyle="bold"/>
<TextView
android:id="#id/txtDescricao"
android:layout_height="fill_parent"
android:layout_weight="2.0"
android:background="#drawable/tabela_conteudo"
android:paddingLeft="3.0dip"
android:text=""
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ff000000"/>
</TableRow>
<TableRow
android:id="#id/tableRow3"
android:layout_height="fill_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:background="#drawable/tabela_conteudo"
android:paddingLeft="3.0dip"
android:text="Endereço:"
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ff000000"
android:textStyle="bold"/>
<TextView
android:id="#id/txtEndereco"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2.0"
android:background="#drawable/tabela_conteudo"
android:paddingLeft="3.0dip"
android:text=""
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ff000000"/>
</TableRow>
<TableRow
android:id="#id/tableRow4"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:background="#drawable/tabela_conteudo"
android:paddingLeft="3.0dip"
android:text="Valor: "
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ff000000"
android:textStyle="bold"/>
<TextView
android:id="#id/txtValor"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="2.0"
android:background="#drawable/tabela_conteudo"
android:paddingLeft="3.0dip"
android:text="R$ 0,00"
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ff000000"/>
</TableRow>
<TableRow
android:id="#id/tableRow5"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:background="#drawable/tabela_conteudo"
android:paddingLeft="3.0dip"
android:text="Telefone: "
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ff000000"
android:textStyle="bold"/>
<TextView
android:id="#id/txtPtoReferencia"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="2.0"
android:autoLink="phone"
android:background="#drawable/tabela_conteudo"
android:paddingLeft="3.0dip"
android:text=""
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ff000000"/>
</TableRow>
</TableLayout>
<ListView
android:id="#+id/pedidos_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"></ListView>
<Button
android:id="#id/btnAceitar"
style="#style/ButtonText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/btn_green"
android:text="Aceitar"/>
<Button
android:id="#id/btnVerMapa"
style="#style/ButtonText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/btn_blue"
android:text="Ver Mapa"/>
<Button
android:id="#id/btnVerOrigemWaze"
style="#style/ButtonText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/btn_blue"
android:text="Ver Local Origem"/>
<Button
android:id="#id/btnVerDestinoWaze"
style="#style/ButtonText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/btn_blue"
android:text="Ver Local Destino"/>
<Button
android:id="#id/btnInformarTmpEstimado"
style="#style/ButtonText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/btn_blue"
android:text="Tempo Estimado"/>
<Button
android:id="#id/btnClienteBordo"
style="#style/ButtonText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/btn_blue"
android:text="Produto Já Recolhido"/>
<Button
android:id="#id/btnInformarValor"
style="#style/ButtonText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/btn_blue"
android:text="Informar Valor"/>
<Button
android:id="#id/btnRejeitar"
style="#style/ButtonText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/btn_red"
android:text="Rejeitar"/>
<Button
android:id="#id/btnCancelarAposAceitar"
style="#style/ButtonText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/btn_red"
android:text="Cancelar Corrida"
android:visibility="invisible"/>
<Button
android:id="#id/btnFinalizar"
style="#style/ButtonText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/btn_blue"
android:text="Finalizar Corrida"
android:visibility="invisible"/>
</LinearLayout>
</ScrollView>
The screen is getting as follows:
http://anstaxi.com.br/android-screen-current-wrong.png
I need all the items are displayed.
The code snippet is:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tela_corrida_multiponto);
String[] mobileArray = {"Android","IPhone","WindowsMobile","Blackberry","WebOS","Ubuntu","Windows7","Max OS X"};
ArrayAdapter adapter = new ArrayAdapter<String>(this, R.layout.activity_listview_pedidos, mobileArray);
ListView listView = (ListView) findViewById(R.id.pedidos_list);
listView.setAdapter(adapter);
}
-
You problem is using a listview inside a scrollview. Listview cant streatch itself inside the scrollview.
And after solving this issue. You will have problem with th scrolling (which one to scroll?)
But this link solves your problem:
Android list view inside a scroll view

Make table row scroll up and down in some period of time automatically

I have create a list of Currency exchange rate by using table with 6 row.
i want 6 row to have some animation like it running up and down automatically in some period of time so it can make user user more attractive on it.
please give me some example or if you have any idea to make table row animation that make more attractive for user.
Move the scrolled position of your view.
public void scrollBy (int x, int y)
Parameters
x - the amount of pixels to scroll by horizontally
y - the amount of pixels to scroll by vertically
lv.scrollBy(100,100) //....like this
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_margin="0sp"
android:layout_weight="0.03"
android:background="#drawable/gradient">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/logo"
android:layout_marginLeft="50dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="35dp"
android:layout_marginTop="10dp"
android:text="GOLDEN ROYAL EXCHANGE"
android:textColor="#ba8707"
android:textStyle="bold"
android:textSize="16sp"
android:backgroundTintMode="multiply"
android:shadowColor="#030303"
android:phoneNumber="true" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="1sp"
android:background="#drawable/lineback"
android:layout_weight="0.62">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/myScrollview"
android:scrollbars="none">
<TableLayout
android:id="#+id/table01"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow
android:background="#4042dba8"
android:id="#+id/khmerrow"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:minHeight="145px"
android:layout_marginTop="3dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="3dp"
android:src="#drawable/khmerflages" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="-8dp"
android:text="Khmer Riel 柬币"
android:textColor="#000000"
android:textSize="13sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="20dp"
android:text="USD/KHR"
android:textColor="#000000"
android:textSize="12sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="30dp"
android:text="4,200"
android:textColor="#000000"
android:textSize="13sp"
android:textStyle="bold" />
</TableRow>
<TableRow android:background="#4042dba8"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:minHeight="145px"
android:layout_marginTop="2.5sp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="3dp"
android:src="#drawable/thaiflags" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="-12dp"
android:layout_gravity="center"
android:text="Thai Baht 泰铢"
android:textColor="#000000"
android:textSize="13sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="25dp"
android:text="USD/THB"
android:textColor="#000000"
android:textSize="12sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="30dp"
android:text="35"
android:textColor="#000000"
android:textSize="13sp"
android:textStyle="bold" />
</TableRow>
<TableRow android:background="#4042dba8"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:minHeight="145px"
android:layout_marginTop="2.5sp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="3dp"
android:src="#drawable/chinaflags" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="-3dp"
android:layout_gravity="center"
android:text="China RMB 人民币"
android:textColor="#000000"
android:textSize="13sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="18dp"
android:text="USD/RMB"
android:textColor="#000000"
android:textSize="12sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="30dp"
android:text="6.7"
android:textColor="#000000"
android:textSize="13sp"
android:textStyle="bold" />
</TableRow>
<TableRow android:background="#4042dba8"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:minHeight="145px"
android:layout_marginTop="2.5sp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="3dp"
android:src="#drawable/hongkongflags" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="9dp"
android:layout_gravity="center"
android:text="HongKong Dollar 港币"
android:textColor="#000000"
android:textSize="13sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="8dp"
android:text="USD/HKD"
android:textColor="#000000"
android:textSize="12sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="30dp"
android:text="8.7"
android:textColor="#000000"
android:textSize="13sp"
android:textStyle="bold" />
</TableRow>
<TableRow android:background="#4042dba8"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:minHeight="145px"
android:layout_marginTop="2.5sp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="3dp"
android:src="#drawable/malaysiaflags" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:layout_gravity="center"
android:text="Malaysia MYR 马币"
android:textColor="#000000"
android:textSize="13sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="15dp"
android:text="USD/MYR"
android:textColor="#000000"
android:textSize="12sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="30dp"
android:text="6.6"
android:textColor="#000000"
android:textSize="13sp"
android:textStyle="bold" />
</TableRow>
<TableRow android:background="#4042dba8"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:minHeight="145px"
android:layout_marginTop="2.5sp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="3dp"
android:src="#drawable/singaporeflags" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:layout_gravity="center"
android:text="Singapore SGD 新币"
android:textColor="#000000"
android:textSize="13sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="15dp"
android:text="USD/SGD"
android:textColor="#000000"
android:textSize="12sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="30dp"
android:text="1.6"
android:textColor="#000000"
android:textSize="13sp"
android:textStyle="bold" />
</TableRow>
<TextView
android:layout_width="match_parent"
android:layout_height="33dp"
android:layout_marginTop="2.5sp"
android:textColor="#000000"
android:id="#+id/date" />
</TableLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="1sp"
android:background="#dee6d461"
android:layout_weight="0.36">
<ViewFlipper
android:id="#+id/bckgrndViewFlipper1"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="#+id/bckgrndImageView8"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="centerCrop"
android:src="#drawable/exchange1" />
<ImageView
android:id="#+id/bckgrndImageView7"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="centerCrop"
android:src="#drawable/exchange2" />
<ImageView
android:id="#+id/bckgrndImageView6"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="centerCrop"
android:src="#drawable/exchange3" />
<ImageView
android:id="#+id/bckgrndImageView5"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="centerCrop"
android:src="#drawable/exchange4" />
<ImageView
android:id="#+id/bckgrndImageView4"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="centerCrop"
android:src="#drawable/exchange5" />
<ImageView
android:id="#+id/bckgrndImageView3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="centerCrop"
android:src="#drawable/exchange6" />
</ViewFlipper>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="25dp"
android:background="#drawable/gradient">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/trading"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:text="Trading Hours .................`enter code here`"
android:textSize="13sp"
android:textColor="#ba8707"/>
</LinearLayout>
</LinearLayout>
public class MainActivity extends AppCompatActivity {
Animation fade_in, fade_out, rowanimation;
ViewFlipper viewFlipper;
ScrollView myView;
TextView date;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
viewFlipper = (ViewFlipper) this.findViewById(R.id.bckgrndViewFlipper1);
fade_in = AnimationUtils.loadAnimation(this,
android.R.anim.fade_in);
fade_out = AnimationUtils.loadAnimation(this,
android.R.anim.fade_out);
viewFlipper.setInAnimation(fade_in);
viewFlipper.setOutAnimation(fade_out);
viewFlipper.setAutoStart(true);
viewFlipper.setFlipInterval(5000);
viewFlipper.startFlipping();
}
}

Android: onClick event listener doesn't work on linearlayout

I am trying to implement an onclick for the entire layout but it won't work.
Here is my function for my RelativeLayout:
public void updateRange(View v)
{
System.out.println("Hello!");
}
and here is my xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context=".MainActivity"
android:background="#ffffffff"
android:id="#+id/xasdf"
android:onClick="updateRange">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/toptab"
android:orientation="horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Settings"
android:fontFamily="monospace"
android:textAllCaps="false"
android:layout_weight="0.333333"
android:id="#+id/settingsButton"
android:background="#fffdb64b" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Solutions"
android:fontFamily="monospace"
android:textAllCaps="false"
android:layout_weight="0.333333"
android:id="#+id/solutionsButton"
android:background="#fffdb64b" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mode"
android:fontFamily="monospace"
android:textAllCaps="false"
android:layout_weight="0.333333"
android:id="#+id/modeButton"
android:background="#fffdb64b" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:gravity="center_vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/chartlayout"
android:layout_below="#+id/toptab"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:weightSum="1"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<EditText
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/textView"
android:layout_weight="0.5"
android:background="#ffffffff"
android:fontFamily="monospace"
android:hint="y = ..." />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Graph"
android:fontFamily="monospace"
android:textAllCaps="false"
android:layout_weight="0.25"
android:id="#+id/button"
android:background="#ffd0d0d0"
android:onClick="drawGraph" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Table"
android:fontFamily="monospace"
android:layout_weight="0.25"
android:textAllCaps="false"
android:id="#+id/button2"
android:background="#ffd0d0d0" />
</LinearLayout>
</RelativeLayout>
Try adding the extra line below to your Relative Layout description:
...
android:onClick="updateRange"
android:clickable="true">

Android How to create rain like animtion?

I want to create a animation with some dots and they are falling from top to bottom. For that I am using a translate animation which moves the dots images from top to bottom. But I want this to be continuous meaning the animation should repeat itself.
I have to create a animation with some dots and they are falling from top to bottom i will post gif animation file , which is my requirement , please anyone guide me how to create this one?
it starts with FadeIn animation it is running fine in my code and then the dots moving in continuous Motion from TOP TO BOTTOM as in gif i have posted it is not working in my code i have created 14 Linearlayouts they contains 7 texviews Horizontally with VISIBILITY.GONE in Oncreate i am changing its VISIBILITY to VISIBLE and starting FADE IN animation and i will post my code , please anyone guide me?
MY REQUIREMNET
rain_like_animation
public class MainActivity extends Activity implements AnimationListener {
LinearLayout move_animation, move_animation1, move_animation2,
move_animation3, move_animation4, move_animation5;
Display display;
Point size2;
int width1, height1;
// Animation
Animation animFadein;
TranslateAnimation translateanimation;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
display = getWindowManager().getDefaultDisplay();
size2 = new Point();
display.getSize(size2);
width1 = size2.x;
height1 = size2.y;
move_animation = (LinearLayout) findViewById(R.id.move_animation);
move_animation1 = (LinearLayout) findViewById(R.id.move_animation1);
move_animation2 = (LinearLayout) findViewById(R.id.move_animation2);
move_animation3 = (LinearLayout) findViewById(R.id.move_animation3);
// load the animation
animFadein = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.fade_in);
// set animation listener
animFadein.setAnimationListener(this);
// (float fromXDelta, float toXDelta, float fromYDelta, float toYDelta)
translateanimation = new TranslateAnimation(0.0f, 0.0f, -50.0f, height1);
translateanimation.setDuration(3000);
translateanimation.setRepeatCount(Animation.INFINITE);
translateanimation.setRepeatMode(Animation.RESTART);
translateanimation.setFillAfter(false);
translateanimation.setAnimationListener(new AnimationListener() {
#Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
Log.e("onAnimationStart", "onAnimationStart");
}
#Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
Log.e("onAnimationRepeat", "onAnimationRepeat");
}
#Override
public void onAnimationEnd(Animation animation) {
// TODO Auto-generated method stub
Log.e("onAnimationEnd", "onAnimationEnd");
}
});
move_animation.setVisibility(View.VISIBLE);
move_animation1.setVisibility(View.VISIBLE);
move_animation2.setVisibility(View.VISIBLE);
move_animation3.setVisibility(View.VISIBLE);
// start the Fadein animation
// =============================================
// =============================================
move_animation.startAnimation(animFadein);
move_animation1.startAnimation(animFadein);
move_animation2.startAnimation(animFadein);
move_animation3.startAnimation(animFadein);
}
#Override
public void onAnimationEnd(Animation animation) {
// Take any action after completing the animation
// start the translate animation when fade-in stops
move_animation.startAnimation(translateanimation);
move_animation1.startAnimation(translateanimation);
move_animation2.startAnimation(translateanimation);
move_animation3.startAnimation(translateanimation);
}
#Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
#Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
}
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/splashimage"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/move_animation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:orientation="horizontal"
android:visibility="gone"
android:weightSum="7" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:text="."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/holo_blue_bright" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:text="."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/holo_red_dark" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:text="."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/holo_blue_bright" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:text="."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/holo_red_dark" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:text="."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/holo_blue_bright" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:text="."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/holo_red_dark" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:text="."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/holo_blue_bright" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/move_animation1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:orientation="horizontal"
android:visibility="gone"
android:weightSum="7" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:text="."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/holo_blue_bright" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:text="."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/holo_red_dark" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:text="."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/holo_blue_bright" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:text="."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/holo_red_dark" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:text="."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/holo_blue_bright" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:text="."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/holo_red_dark" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:text="."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/holo_blue_bright" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/move_animation2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:orientation="horizontal"
android:visibility="gone"
android:weightSum="7" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:text="."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/holo_blue_bright" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:text="."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/holo_red_dark" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:text="."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/holo_blue_bright" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:text="."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/holo_red_dark" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:text="."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/holo_blue_bright" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:text="."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/holo_red_dark" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:text="."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/holo_blue_bright" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/move_animation3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:orientation="horizontal"
android:visibility="gone"
android:weightSum="7" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:text="."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/holo_blue_bright" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:text="."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/holo_red_dark" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:text="."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/holo_blue_bright" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:text="."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/holo_red_dark" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:text="."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/holo_blue_bright" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:text="."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/holo_red_dark" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:text="."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/holo_blue_bright" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Download this library https://github.com/plattysoft/Leonids
Add this to your project dependency
then
new ParticleSystem(RainActivity.this, 80, R.drawable.rain_drop, 10000)
.setSpeedByComponentsRange(0f, 0f, 0.05f, 0.1f)
.setAcceleration(0.00005f, 90)
.emitWithGravity(findViewById(R.id.cloud), Gravity.BOTTOM, 8);
It will look like

Categories

Resources