Play several mp3 files in one Onclick statement? - java

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.

Related

Markers title and Traffic view, googlemap android

i am facing some problems with anable and disable traffic TYPE on the google map when OnMapReady.I have tow differents MAP_TYPE_NORMAL and MAP_TYPE_HYBRID.
what i want is to setOnclickListener when button is clicked.
my button code:
maptrafic.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if(map.getMapType() == GoogleMap.MAP_TYPE_NORMAL || map.getMapType() == GoogleMap.MAP_TYPE_HYBRID){
map.setTrafficEnabled(true);
maptrafic.setImageResource(R.drawable.trafficmap_on);
}
else {
map.setTrafficEnabled(false);
maptrafic.setImageResource(R.drawable.trafficmap_off);
map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
}
}
});
also, i am working on googlemap using REST API i have successfuly create windowsInfoMarker but what i need is when map ready is to see the marker name only not all information like windowsInfoMarker but only Markers with name.
my MapActivity code shared from drive
MapActivity.java
my activity_map.xml
<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:orientation="vertical"
android:id="#+id/drawer"
android:layout_height="match_parent"
tools:context=".activities.MapActivity">
<RelativeLayout
android:id="#+id/mapfloating"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--inclusion de la carte-->
<include layout="#layout/include_main_map" />
<!--fin inclusion de la carte-->
<com.getbase.floatingactionbutton.FloatingActionsMenu
android:id="#+id/mainFloatingBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_margin="25dp"
app:fab_labelStyle="#style/custom_floating_buttons"
android:layout_alignParentBottom="true"
app:fab_addButtonColorNormal="#color/blue">
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="#+id/evennements"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fab_icon="#drawable/icon_events"
app:fab_title="Evennements"
android:background="#drawable/cerclebackground"
app:fab_colorNormal="#color/purple_500"/>
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="#+id/historiques"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fab_icon="#drawable/icon_history"
app:fab_title="Historique"
android:background="#drawable/cerclebackground"
app:fab_colorNormal="#color/purple_500"/>
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="#+id/reglages"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fab_icon="#drawable/icon_setup"
app:fab_title="Reglages"
android:background="#drawable/cerclebackground"
app:fab_colorNormal="#color/purple_500"/>
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="#+id/aide_support"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fab_icon="#drawable/icon_support"
app:fab_title="Aide/Support"
android:background="#drawable/cerclebackground"
app:fab_colorNormal="#color/purple_500"/>
</com.getbase.floatingactionbutton.FloatingActionsMenu>
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="#+id/floatingPopUpLeft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_marginStart="10dp"
android:layout_marginTop="5dp"
android:contentDescription="#string/app_name"
app:fab_colorDisabled="#color/white"
app:fab_colorNormal="#color/white"
app:fab_colorPressed="#color/blue"
app:fab_icon="#drawable/ic_menu_24" />
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="#+id/floatingPopUpRight"
style="#style/custom_floating_buttons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="5dp"
android:layout_marginEnd="10dp"
android:contentDescription="#string/app_name"
app:fab_colorDisabled="#color/white"
app:fab_colorNormal="#color/white"
app:fab_colorPressed="#color/blue"
app:fab_icon="#drawable/ic_baseline_notifications_active_24" />
</RelativeLayout>
</RelativeLayout>
my include_mean_map
<?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:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/content_layout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true" />
<LinearLayout
android:id="#+id/zoomio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_above="#+id/fonctio"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="290dp"
android:layout_marginStart="9dp">
<ImageButton
android:id="#+id/zoom_in"
android:layout_width="30dp"
android:layout_height="30dp"
android:src="#drawable/zoom_in_selector"
android:layout_marginStart="4dp"
tools:ignore="ContentDescription" />
<ImageButton
android:id="#+id/zoom_out"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginStart="4dp"
android:layout_marginTop="5dp"
android:src="#drawable/zoom_out_selector"
tools:ignore="ContentDescription,TouchTargetSizeCheck,SpeakableTextPresentCheck" />
</LinearLayout>
<LinearLayout
android:id="#+id/fonctio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="5dp"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="70dp"
android:layout_marginStart="9dp">
<ImageButton
android:id="#+id/showtails"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginTop="5dp"
android:src="#drawable/tail_active"
tools:ignore="ContentDescription,TouchTargetSizeCheck" />
<ImageButton
android:id="#+id/autozoom"
android:layout_width="40dp"
android:layout_height="40dp"
android:src="#drawable/icon2022"
android:layout_marginTop="5dp"
tools:ignore="ContentDescription" />
<ImageButton
android:id="#+id/geofences"
android:layout_width="40dp"
android:layout_height="40dp"
android:src="#drawable/geofence_active"
android:layout_marginTop="5dp"
tools:ignore="ContentDescription" />
<ImageButton
android:id="#+id/map_layer"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginTop="5dp"
android:src="#drawable/map_layer_change_icon_inactive"
tools:ignore="ContentDescription,TouchTargetSizeCheck" />
<ImageButton
android:id="#+id/map_trafic"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="#drawable/grey_round_rect"
android:layout_marginTop="5dp"
android:src="#drawable/trafficmap_on"
tools:ignore="ContentDescription" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/loading_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:visibility="gone"
android:gravity="center">
<me.zhanghai.android.materialprogressbar.MaterialProgressBar
android:layout_width="50dp"
android:layout_height="50dp"
android:indeterminate="true"
style="#style/Widget.MaterialProgressBar.ProgressBar.Horizontal" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/nodata_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:visibility="gone"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="#string/noMapData"/>
</RelativeLayout>
</RelativeLayout>
if you have any idea please don't ready only i need help. any idea are welcome.
if you need more details juste ask i am online 24/7 each second.

How to make an own time table in android studio

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?

ListView in ScrollView not displaying all items Android [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I have some problem ListView in ScrollView not displaying all items
and I try this code, it works but it takes a long time to process in the Adapter.
I have tried this code which is faster but doesn't display all items
How do I fix it?
Note: my ListView id is lv_poll_feed
<?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:background="#color/color_white">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/lay_edit_comment"
android:scrollbars="none">
<RelativeLayout
android:id="#+id/lay_big"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/lay_body_timeline_detail_detail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/view_line_4">
<TextView
android:id="#+id/tx_time_timeline_detail_user"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:padding="10dp"
android:text="-"
android:textColor="#color/color_gray_light"
android:textSize="#dimen/tx_size_smally_time"/>
<RelativeLayout
android:id="#+id/lay_profile_detail_detail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/tx_time_timeline_detail_user"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp">
<TextView
android:id="#+id/tx_timeline_detail_detail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:padding="10dp"
android:text="-"
android:textColor="#color/tx_color_token"
android:textSize="#dimen/tx_size_small"/>
<RelativeLayout
android:id="#+id/lay_center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/tx_timeline_detail_detail"
android:layout_marginBottom="5dp"
android:layout_marginTop="10dp"
android:gravity="center"
android:visibility="visible">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/tx_catego_topic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:background="#drawable/bg_button"
android:padding="5dp"
android:text="xxxxxxx"
android:textColor="#color/color_white"
android:textSize="#dimen/tx_size_small"
android:visibility="gone"/>
<com.cunoraz.tagview.TagView xmlns:tagview="http://schemas.android.com/apk/res-auto"
android:id="#+id/tagCloudLinkView_topic"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
tagview:lineMargin="5dp"
tagview:tagMargin="5dp"
tagview:theme="#style/AppTheme"/>
<ListView
android:id="#+id/lv_poll_feed"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:divider="#null"
android:visibility="visible">
</ListView>
</LinearLayout>
</RelativeLayout>
<ImageView
android:id="#+id/img_timeline_profile_detail_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/tx_timeline_detail_detail"
android:adjustViewBounds="true"
android:visibility="visible"/>
</RelativeLayout>
<RelativeLayout
android:id="#+id/lay_timeline_detail_emoji"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/lay_profile_detail_detail"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:focusable="false"
android:focusableInTouchMode="false"
android:padding="10dp">
<LinearLayout
android:id="#+id/lay_big_emoji"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="visible"
android:weightSum="3">
<LinearLayout
android:id="#+id/lay_emoji1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:orientation="horizontal"
android:visibility="visible">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/amazed_1"/>
<TextView
android:id="#+id/tx_number_emoji_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text=""
android:textSize="#dimen/tx_size_smally_time"/>
</LinearLayout>
<LinearLayout
android:id="#+id/lay_emoji2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="0"
android:orientation="horizontal"
android:visibility="visible">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/funny_2"/>
<TextView
android:id="#+id/tx_number_emoji_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text=""
android:textSize="#dimen/tx_size_smally_time"/>
</LinearLayout>
<LinearLayout
android:id="#+id/lay_emoji3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="0"
android:orientation="horizontal"
android:visibility="visible">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/love_3"/>
<TextView
android:id="#+id/tx_number_emoji_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="#dimen/tx_size_smally_time"/>
</LinearLayout>
<LinearLayout
android:id="#+id/lay_emoji4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="0"
android:orientation="horizontal"
android:visibility="visible">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/sorrow_2"/>
<TextView
android:id="#+id/tx_number_emoji_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text=""
android:textSize="#dimen/tx_size_smally_time"/>
</LinearLayout>
<LinearLayout
android:id="#+id/lay_emoji5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="0"
android:orientation="horizontal"
android:visibility="visible">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/anger_5"/>
<TextView
android:id="#+id/tx_number_emoji_5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text=""
android:textSize="#dimen/tx_size_smally_time"/>
</LinearLayout>
<LinearLayout
android:id="#+id/lay_emoji6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="0"
android:orientation="horizontal"
android:visibility="visible">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/horrified_6"/>
<TextView
android:id="#+id/tx_number_emoji_6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text=""
android:textSize="#dimen/tx_size_smally_time"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<View
android:id="#+id/view_line_5"
android:layout_below="#+id/lay_timeline_detail_emoji"
android:layout_marginTop="5dp"
android:background="#color/text_bottombar"/>
<RelativeLayout
android:id="#+id/lay_body_quest_topic"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/view_line_5"
android:layout_marginTop="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="6">
<LinearLayout
android:id="#+id/lay_timeline_detail_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="2"
android:focusable="false"
android:focusableInTouchMode="false"
android:gravity="center"
android:orientation="horizontal"
android:padding="5dp">
<ImageView
android:id="#+id/img_up"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/up_1"/>
<TextView
android:id="#+id/tx_timeline_detail_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:text="#string/tx_up"
android:textColor="#color/tx_color_token"
android:textSize="#dimen/tx_size_smally"/>
<TextView
android:id="#+id/tx_timeline_detail_number_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text=" 53"
android:textColor="#color/tx_color_token"
android:textSize="#dimen/tx_size_smally"/>
</LinearLayout>
<LinearLayout
android:id="#+id/lay_timeline_detail_comment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="2"
android:gravity="center"
android:orientation="horizontal"
android:padding="5dp">
<ImageView
android:id="#+id/img_comment"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/comment_1"/>
<TextView
android:id="#+id/tx_timeline_detail_comment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:text="#string/tx_comment"
android:textColor="#color/tx_color_token"
android:textSize="#dimen/tx_size_smally"/>
<TextView
android:id="#+id/tx_timeline_detail_number_comment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text=" 53"
android:textColor="#color/tx_color_token"
android:textSize="#dimen/tx_size_smally"/>
</LinearLayout>
<LinearLayout
android:id="#+id/lay_profile_detail_share"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="2"
android:gravity="center"
android:orientation="horizontal"
android:padding="5dp">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/share_1"/>
<TextView
android:id="#+id/tx_timeline_detail_share"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:text="#string/tx_share"
android:textColor="#color/tx_color_token"
android:textSize="#dimen/tx_size_smally"/>
<TextView
android:id="#+id/tx_timeline_detail_number_share"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text=" "
android:textColor="#color/tx_color_token"
android:textSize="#dimen/tx_size_smally"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<View
android:id="#+id/view_line_3"
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_below="#+id/lay_body_quest_topic"
android:layout_marginTop="5dp"
android:background="#color/bottombar"/>
<RelativeLayout
android:id="#+id/lay_timeline_detail_select_emoji_profile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/lay_body_quest_topic"
android:layout_marginBottom="-10dp"
android:background="#drawable/bg_emoji"
android:visibility="gone">
<LinearLayout
android:id="#+id/lay_star"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/tx_name_detail"
android:gravity="center"
android:orientation="horizontal">
<RadioGroup
android:id="#+id/radioGroupQuest"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal"
android:padding="0dp">
<RadioButton
android:id="#+id/emoji1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:background="#drawable/img_emoji_amazed"
android:button="#android:color/transparent"
android:checked="false"
android:gravity="center"/>
<RadioButton
android:id="#+id/emoji2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:background="#drawable/img_emoji_funny"
android:button="#android:color/transparent"
android:checked="false"/>
</RadioGroup>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
</ScrollView>
You should not add same direction scrolling layout inside another scrolling layout. Result will not always intended. Here your listview is wrapping to single element of your ListView because you have added it inside Scrollview. You should not do that in first place but if you can't change your layout then do the following changes:
Change ListView to RecyclerView and change the adapter accordingly.
Also, change ScrollView to NestedScrollView.
You can use this function :
public static void setListViewHeight(ListView listView) {
ListAdapter listAdapter = listView.getAdapter();
if (listAdapter == null)
return;
int desiredWidth = MeasureSpec.makeMeasureSpec(listView.getWidth(), MeasureSpec.UNSPECIFIED);
int totalHeight = 0;
View view = null;
for (int i = 0; i < listAdapter.getCount(); i++) {
view = listAdapter.getView(i, view, listView);
if (i == 0)
view.setLayoutParams(new ViewGroup.LayoutParams(desiredWidth, LayoutParams.WRAP_CONTENT));
view.measure(desiredWidth, MeasureSpec.UNSPECIFIED);
totalHeight += view.getMeasuredHeight();
}
ViewGroup.LayoutParams params = listView.getLayoutParams();
params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
listView.setLayoutParams(params);
}
and set like this :
ListView list = (ListView) view.findViewById(R.id.listview);
setListViewHeight(list);

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