Please see below screenshot for different results on tablet and on phones.
activity.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:id="#+id/frameLayout1"
android:weightSum="4"
android:padding="0dp"
android:orientation="vertical">
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="centerCrop"
android:src="#drawable/crossword_background"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="0dp"
android:orientation="vertical"
android:id="#+id/frameLayout"
android:weightSum="4"
>
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:background="#android:color/transparent" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/tvTitle"
style="#style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:layout_width="100dp"
android:layout_height="24dp"
android:layout_marginStart="4dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="4dp"
android:layout_marginBottom="4dp"
android:background="#drawable/count_frame"
android:fontFamily="#font/roboto"
android:gravity="center"
android:textColor="#5A0FC8"
android:textSize="13sp"
android:textStyle="bold"
tools:text="4" />
<TextView
android:id="#+id/menu_item_score"
style="#style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:layout_width="100dp"
android:layout_height="24dp"
android:layout_margin="4dp"
android:background="#drawable/count_frame"
android:gravity="right"
android:layout_alignParentRight="true"
android:textColor="#5A0FC8"
android:textSize="13sp"
android:textStyle="bold"
android:textAlignment="center"
tools:text="4" />
</RelativeLayout>
</androidx.appcompat.widget.Toolbar>
<LinearLayout
android:id="#+id/rightLayout"
android:layout_width="40dp"
android:layout_height="fill_parent"
android:layout_alignParentEnd="true"
android:layout_below="#id/horizontal_divider"
android:orientation="vertical" >
<LinearLayout
android:layout_weight="1"
android:layout_height="fill_parent"
android:layout_width="match_parent"
android:weightSum="4"
android:orientation="vertical" >
<ImageButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/ic_action_360"
android:background="#null"/>
<ImageButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/ic_action_360"
android:background="#null"/>
<ImageButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/ic_action_360"
android:background="#null"/>
<ImageButton
android:id="#+id/ShowHint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/ic_action_360"
android:background="#null"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/leftLayout"
android:layout_width="40dp"
android:layout_height="fill_parent"
android:layout_alignParentStart="true"
android:layout_below="#id/horizontal_divider"
android:orientation="vertical" >
<LinearLayout
android:layout_weight="1"
android:layout_height="fill_parent"
android:layout_width="match_parent"
android:weightSum="4"
android:orientation="vertical" >
<ImageButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/ic_action_360"
android:background="#null"/>
<ImageButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/ic_action_360"
android:background="#null"/>
<ImageButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/ic_action_360"
android:background="#null"/>
<ImageButton
android:id="#+id/ShuffleButtons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/ic_action_360"
android:background="#null"/>
</LinearLayout>
</LinearLayout>
<View
android:id="#+id/horizontal_divider"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_centerVertical="true" />
<RelativeLayout
android:id="#+id/firstLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="0dp"
android:layout_centerInParent="true"
android:layout_margin="0dp"
android:layout_above="#+id/horizontal_divider"
android:layout_below="#id/toolbar"
android:gravity="center">
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/tblLayout"
android:gravity="center"
android:padding="0dip"
android:shrinkColumns="*"
android:layout_margin="0dip"
android:layout_centerInParent="true"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true">
</TableLayout>
</RelativeLayout >
<LinearLayout
android:id="#+id/secondLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/horizontal_divider"
android:layout_toStartOf="#id/rightLayout"
android:layout_toEndOf="#id/leftLayout"
android:orientation="vertical" >
<FrameLayout
android:id="#+id/frame_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="5dp"
>
</FrameLayout>
</LinearLayout>
</RelativeLayout>
background_ic_btn_bonus.xml
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="#drawable/ic_btn_bonus"
android:tileMode="disabled" android:gravity="center" >
</bitmap>
background_ic_btn_default.xml
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="#drawable/ic_btn_default"
android:tileMode="disabled" android:gravity="center" >
</bitmap>
Corresponding Java Code
String[] iLayoutMap = getTableLayout();
/*
iLayoutMap contains split rows removing 2
2,0,0,0,0,0,0,2,0,0,0,0,0,0,2,0,0,1,1,1,0,2,0,0,0,1,0,0,2,0,0,0,0,0,0,2,0,0,0,0,0,0*/
TableLayout tableLayout = (TableLayout) findViewById(R.id.tblLayout);
for(int i=1;i<iLayoutMap.length;i++){
TableRow NewRow1 =new TableRow(this);
NewRow1.setPadding(0, 0, 0, 0);
NewRow1.setGravity(Gravity.CENTER);
NewRow1.setHorizontalGravity(Gravity.CENTER);
NewRow1.setVerticalGravity(Gravity.CENTER);
String [] items = iLayoutMap[i].split("\\s*,\\s*");
NewRow1.setWeightSum(items.length-1);
for(int j = 0; j < items.length;j++) {
if(items[j].equalsIgnoreCase("0")){
Button btnAdd = new Button(context);
btnAdd.setGravity(Gravity.CENTER);
btnAdd.setTextSize(25);
btnAdd.setTextColor(Color.WHITE);
//btnAdd.setPadding(10 ,10,10,10);
//btnAdd.setBackgroundResource(R.drawable.ic_btn_default);
btnAdd.setBackgroundResource(R.drawable.background_ic_btn_default);
btnAdd.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,TableRow.LayoutParams.WRAP_CONTENT ,1));
NewRow1.addView(btnAdd);
}else if(items[j].equalsIgnoreCase("1")){
//https://stackoverflow.com/questions/3404582/adding-text-to-imageview-in-android
Button btnAdd = new Button(context);
String strId = Integer.toString(i) + Integer.toString(j-1);
//btnAdd.setWidth(iObjectWidth);
//btnAdd.setHeight(iObjectHeight);
btnAdd.setId(Integer.valueOf(strId));
btnAdd.setGravity(Gravity.CENTER);
btnAdd.setTextSize(25);
btnAdd.setTextColor(Color.WHITE);
//btnAdd.setPadding(10 ,10,10,10);
//btnAdd.setBackgroundResource(R.drawable.ic_btn_default);
btnAdd.setBackgroundResource(R.drawable.background_ic_btn_bonus);
btnAdd.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,TableRow.LayoutParams.WRAP_CONTENT,1 ));
NewRow1.addView(btnAdd);
}
}
NewRow1.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT,TableLayout.LayoutParams.WRAP_CONTENT,items.length-1));
tableLayout.addView(NewRow1);
}
Function
public String[] getTableLayout() {
if (lvlinfo != null) {
return lvlinfo.getLayout().split("2");
}
//Return this as default in case of failure
String arr = "2,0,0,0,0,0,0,2,0,0,0,0,0,0,2,0,0,1,1,1,0,2,0,0,0,1,0,0,2,0,0,0,0,0,0,2,0,0,0,0,0,0";
//String arr = "2,0,0,0,0,0,0,2,0,0,0,0,0,0,2,0,0,1,1,1,0,2,0,0,0,1,0,0,2,0,0,0,0,0,0,2,0,0,0,0,0,0";
return arr.split("2");
}
Expected Result ( Working correctly on Tablet with Android 4.4.2 with below code)
Actual Results ( Tested on multiple phones with OS >= 8.1.0)
I Have tried your code but unable to reproduce this output
For me your code is working fine check the output
Result in Oreo
Result in android pie
Result in android Q
as per my opinion you should use
You should use RecyclerView with GridLayoutManager
Follow this sample code
Add one recyclerview in your activity layout xml file
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/firstLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="0dp"
android:gravity="center">
<androidx.recyclerview.widget.RecyclerView
android:layout_width="wrap_content"
android:id="#+id/gridRecyclerView"
android:layout_centerInParent="true"
android:layout_height="wrap_content"/>
</RelativeLayout>
Now inside your activity set GridLayoutManager to your RecyclerView
GridLayoutManager (Context context,
int spanCount)
Creates a vertical GridLayoutManager
Parameters
context Context: Current context, will be used to access resources.
spanCount int: The number of columns in the grid
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
public class JavaActivity extends AppCompatActivity {
RecyclerView myRecyclerView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_java);
myRecyclerView = findViewById(R.id.gridRecyclerView);
GridLayoutManager gridLayoutManager = new GridLayoutManager(JavaActivity.this, 6);
myRecyclerView.setLayoutManager(gridLayoutManager);
myRecyclerView.setAdapter(new MyAdapter(this));
}
}
Create one adapter class RecyclerView like this
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyViewHolder> {
private Context context;
public MyAdapter(Context context) {
this.context = context;
}
#NonNull
#Override
public MyViewHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(context).inflate(R.layout.row_list_item, parent, false);
return new MyViewHolder(view);
}
#Override
public void onBindViewHolder(#NonNull MyViewHolder holder, int position) {
if (position%2==0){
holder.imgBanner.setBackgroundColor(Color.BLUE);
}else {
holder.imgBanner.setBackgroundColor(Color.GREEN);
holder.imgBanner.setImageResource(R.drawable.red_heart);
}
}
#Override
public int getItemCount() {
return 36;
}
public class MyViewHolder extends RecyclerView.ViewHolder {
ImageView imgBanner;
public MyViewHolder(#NonNull View itemView) {
super(itemView);
imgBanner = itemView.findViewById(R.id.imgBanner);
}
}
}
Create one layout file for RecyclerView item
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_margin="2dp"
android:orientation="vertical">
<ImageView
android:id="#+id/imgBanner"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="#string/app_name"
/>
</RelativeLayout>
Try with a padding like this:
<RelativeLayout
android:id="#+id/firstLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="someDp" ->>>> Padding
android:paddingRight="someDp" ->>>> Padding
android:layout_above="#+id/horizontal_divider"
android:layout_below="#id/toolbar"
android:gravity="center">
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/tblLayout"
android:gravity="center"
android:shrinkColumns="*"
android:padding="0dip"
android:layout_margin="0dip"
android:layout_centerInParent="true"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"></TableLayout>
</RelativeLayout >
Hi I want to create a responsive scrollable grids. As I search, I came across some codes. I tweaked this code to allow scrolling of the grids. The code creates a 2 column grids and 4 rows with cardViews. The cardViews shrinks to allow more cards into the viewport rather than scrolling. Am open to any ideas and alternative methods to make this work.Thanks in advance.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
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"
tools:context=".MainActivity"
android:scrollbars="vertical"
android:fillViewport="true">
<LinearLayout
android:orientation="vertical"
android:weightSum="10"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_weight="2"
android:layout_width="match_parent"
android:layout_height="0dp">
<TextView
android:id="#+id/textGrid"
android:text="Games"
android:textSize="34sp"
android:textColor="#android:color/black"
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
<android.support.v7.widget.GridLayout
android:id="#+id/gridView"
android:layout_weight="8"
app:columnCount="2"
app:rowCount="2"
android:padding="14dp"
app:alignmentMode="alignMargins"
app:columnOrderPreserved="false"
android:layout_width="match_parent"
android:layout_height="0dp"
>
<android.support.v7.widget.CardView
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"
app:cardCornerRadius="8dp"
app:cardElevation="8dp"
app:layout_columnWeight="1"
app:layout_rowWeight="1">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_margin="16dp"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="#drawable/sampleimage" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Grid One
android:textAlignment="center"
android:textColor="#000"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
</android.support.v7.widget.CardView>
</android.support.v7.widget.GridLayout>
</LinearLayout>
</ScrollView>
I have a pattern like that in one of my apps. Tickets get added to the 3-wide grid and you can scroll the grid. Here is the code I use.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/your_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:baselineAligned="false"
android:orientation="vertical">
<ScrollView
android:id="#+id/your_scrollview"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="2dip"
android:layout_gravity="center_horizontal">
<LinearLayout
android:id="#+id/your_grid"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical"
android:visibility="visible">
<GridView
android:id="#+id/gridViewTickets"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:numColumns="3"
android:padding="8dp"
android:horizontalSpacing="8dp"
android:verticalSpacing="8dp"
android:minHeight="250dip"
android:gravity="center_horizontal"
android:layout_gravity="center_horizontal">
</GridView>
</LinearLayout>
</ScrollView
</LinearLayout>
After a lot of research I came across RecyclerView. It was a little confusing but it worked fine. I had to use two(2) layouts (activity_main.xml and row_data.xml) with MainActivity.java.
activity_main.xml
<?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"
tools:context="MainActivity">
<GridView
android:id="#+id/gridview"
android:numColumns="2"
android:verticalSpacing="1dp"
android:background="#e5e5e5"
android:horizontalSpacing="1dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</GridView>
</RelativeLayout>
row_data.xml
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.CardView
android:id="#+id/gridviewdata"
android:layout_margin="12dp"
app:cardCornerRadius="12dp"
app:cardElevation="6dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_centerInParent="true"
>
<LinearLayout
android:orientation="vertical"
android:padding="16dp"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/images"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="#drawable/apple" />
<TextView
android:id="#+id/fruits"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="Apple something"
android:textStyle="normal|italic"
android:textSize="25dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
MainActivity.java
package com.example.gridrecycler;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
GridView gridView;
String[] fruitNames = {"Apple","Orange","strawberry","Melon","Kiwi","Banana"};
int[] fruitImages = {R.drawable.apple,R.drawable.oranges,R.drawable.strawberry,R.drawable.watermelon,R.drawable.kiwi,R.drawable.banana};
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//finding listview
gridView = findViewById(R.id.gridview);
CustomAdapter customAdapter = new CustomAdapter();
gridView.setAdapter(customAdapter);
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
// Toast.makeText(getApplicationContext(),fruitNames[i],Toast.LENGTH_LONG).show();
Intent intent = new Intent(getApplicationContext(),GridItemActivity.class);
intent.putExtra("name",fruitNames[i]);
intent.putExtra("image",fruitImages[i]);
startActivity(intent);
}
});
}
private class CustomAdapter extends BaseAdapter {
#Override
public int getCount() {
return fruitImages.length;
}
#Override
public Object getItem(int i) {
return null;
}
#Override
public long getItemId(int i) {
return 0;
}
#Override
public View getView(int i, View view, ViewGroup viewGroup) {
View view1 = getLayoutInflater().inflate(R.layout.row_data,null);
//getting view in row_data
TextView name = view1.findViewById(R.id.fruits);
ImageView image = view1.findViewById(R.id.images);
name.setText(fruitNames[i]);
image.setImageResource(fruitImages[i]);
return view1;
}
}
}
I watched diff tuts to come up with this. Am now doubting whether it comforms to best practices. Thanks to you all for your suggestions.
I have a ListView, where i changed appearence of row, but listview have size of one row, instead of fullscreen.
and my scrollview is working but listview is not working.
activity_graph_view.xml
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_graph_table_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="00dp"
android:background="#color/background"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/container_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar" />
</LinearLayout>
</android.support.design.widget.AppBarLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/appbar"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp">
<LinearLayout
android:id="#+id/layoutTableOne"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="5dp"
android:visibility="visible">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="Table View"
android:textSize="#dimen/subheading"
android:textColor="#color/subheading"
android:textAllCaps="false" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ListView
android:id="#+id/lv_spirometer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#color/mdtp_button_selected"
android:dividerHeight="1dp" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:visibility="visible"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp"
android:weightSum="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.9"
android:padding="10dp"
android:text="Graph View"
android:textAllCaps="false"
android:textColor="#color/subheading"
android:textSize="#dimen/subheading" />
</LinearLayout>
<com.jjoe64.graphview.GraphView
android:id="#+id/grapfinal"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_weight="1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp"
android:weightSum="1">
<LinearLayout
android:id="#+id/grphtextMain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/grphtextColor"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_marginTop="3dp"
android:orientation="vertical" />
<TextView
android:id="#+id/grphtext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="Hello"
android:textColor="#color/subheading"
android:textSize="14dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/grphtextMain2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/grphtextColor2"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_marginTop="3dp"
android:background="#color/red_btn_bg_color"
android:orientation="vertical" />
<TextView
android:id="#+id/grphtext2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="Hello"
android:textColor="#color/subheading"
android:textSize="14dp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:visibility="visible"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp"
android:weightSum="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.9"
android:padding="10dp"
android:text="Graph View"
android:textAllCaps="false"
android:textColor="#color/subheading"
android:textSize="#dimen/subheading" />
</LinearLayout>
<com.jjoe64.graphview.GraphView
android:id="#+id/grapfinal1"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_weight="1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp"
android:weightSum="1">
<LinearLayout
android:id="#+id/grphtextMain1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/grphtextColor1"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_marginTop="3dp"
android:background="#color/red_btn_bg_color"
android:orientation="vertical" />
<TextView
android:id="#+id/grphtext1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="Hello"
android:textColor="#color/subheading"
android:textSize="14dp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</ScrollView>
</RelativeLayout>
spirometer_item.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
app:cardBackgroundColor="#fff4f4f3"
app:cardElevation="10dp"
app:cardPreventCornerOverlap="true"
card_view:cardCornerRadius="8dp">
<LinearLayout
android:padding="5dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/tv_date"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:text="" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_marginLeft="10dp"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/tv_fvc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="FVC 3.15 L" />
<TextView
android:id="#+id/tv_fev1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="FEV1 2.44 L" />
<TextView
android:id="#+id/tv_pef"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="PEF 3.74 L/s" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
CustomAdapter1.java
public class CustomAdapter1 extends BaseAdapter {
ArrayList<GetUserSpirometer> arrayList;
public CustomAdapter1(ArrayList<GetUserSpirometer> arrayList){
this.arrayList=arrayList;
Log.e("arraylist length",""+arrayList.size());
}
#Override
public int getCount() {
return arrayList.size();
}
#Override
public Object getItem(int position) {
return position;
}
#Override
public long getItemId(int position) {
return position;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater= getLayoutInflater();
ViewHolder1 holder=new ViewHolder1();
convertView = inflater.inflate(R.layout.spirometer_item, parent, false);
holder.tv_date=(TextView)convertView.findViewById(R.id.tv_date);
holder.tv_fvc=(TextView)convertView.findViewById(R.id.tv_fvc);
holder.tv_fev1=(TextView)convertView.findViewById(R.id.tv_fev1);
holder.tv_pef=(TextView)convertView.findViewById(R.id.tv_pef);
String[] arr = getDate(Long.parseLong(arrayList.get(position).get_date()), "MMM dd, yyy/hh:mm a").split("/");
holder.tv_date.setText(arr[0] + "\n" + arr[1]);
holder.tv_fvc.setText(arrayList.get(position).get_userfvc());
holder.tv_fev1.setText(arrayList.get(position).get_userfev1());
holder.tv_pef.setText(arrayList.get(position).get_userpef());
convertView.setTag(holder);
return convertView;
}
}
Items are not scrolling.
how to solve this. please help.
thanks in advance.
Then you need to change itemView's xml file ,
android:layout_height="match_parent"
instead of like ,
android:layout_height="wrap_content"
Simple change in spirometer_item.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
....Your design code
</LinearLayout>
I was having problem with the same from such a long time. Then I found a solution that worked for me.
Add a ListViewHelper java class. Here below is code for ListViewHelper.java
package com.molescope;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListAdapter;
import android.widget.ListView;
public class ListViewHelper {
public static void getListViewSize(ListView listView){
ListAdapter adapter = listView.getAdapter();
if(adapter!=null){
int totalHeight = 0;
//setting list adapter in loop tp get final size
for (int i=0; i<adapter.getCount(); i++){
View listItem = adapter.getView(i, null, listView);
listItem.measure(0,0);
totalHeight += listItem.getMeasuredHeight();
}
//setting listview items in adapter
ViewGroup.LayoutParams params = listView.getLayoutParams();
params.height = totalHeight + (listView.getDividerHeight() *
(adapter.getCount()-1));
listView.setLayoutParams(params);
}else{
return;
}
}
}
And after adding this java file, in your code wherever you are setting adapter to listview, right after that line add the code below:
ListView myList=(ListView) findViewById(R.id.listView);
myList.setAdapter(new ArrayAdapter<String>.
(this,android.R.layout.simple_list_item_1, listview_array));
ListViewHelper.getListViewSize(myList);
I'm trying to add a subview below another view after an animation. anyone have any idea what i'm doing wrong?
this.animate().translationY(newY - 170).setDuration(500).withEndAction(new Runnable() {
#Override
public void run() {
clearAnimation();
RouteBreakDownLayout routeBreakDownLayout = new RouteBreakDownLayout(mContext);
RelativeLayout.LayoutParams p = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
p.addRule(RelativeLayout.BELOW, R.id.selected_route_layout);
routeBreakDownLayout.setLayoutParams(p);
addView(routeBreakDownLayout);
}
}).start();
Here is the XML for the layout. I have a scrollview embeded which will hold the content that needs to be animated in.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/selected_route_layout2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="#+id/selected_route_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_gravity="bottom"
android:layout_alignParentBottom="true"
android:background="#FFF"
android:gravity="bottom"
android:padding="10dip">
<TextView
android:id="#+id/time_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginRight="10dp"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#1D1C18" />
<TextView
android:id="#+id/eta_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/time_label"
android:layout_toEndOf="#+id/time_label"
android:layout_toRightOf="#+id/time_label"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#7EC82F" />
<LinearLayout
android:id="#+id/route_breakdown"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/time_label"
android:layout_centerVertical="true"
android:layout_marginBottom="10dip"
android:layout_marginTop="10dip"
android:gravity="center_vertical"
android:orientation="horizontal" />
<TextView
android:id="#+id/via_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/route_breakdown"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#BDBDBD" />
<ImageButton
android:id="#+id/arrow_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="#null"
android:padding="15dip"
android:src="#drawable/transit_symbol_up_arrow" />
</RelativeLayout>
<ScrollView
android:layout_below="#+id/selected_route_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:showDividers="middle"
android:divider="?android:dividerHorizontal"
android:animateLayoutChanges="true"
android:paddingLeft="16dp"
android:paddingRight="16dp" />
</ScrollView>
</RelativeLayout>
What goes wrong for you in your code-snippet?
Here's working example I came up with:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/containerRelativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:id="#+id/headerView"
android:background="#00FF00"
android:layout_width="match_parent"
android:layout_height="25dp"/>
<View
android:id="#+id/detailsView"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="40dp"
android:clickable="true"
android:background="#FF0000"/>
</RelativeLayout>
And MainActivity is
package klogi.com.animationstestapp;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.RelativeLayout;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final View detailsView = findViewById(R.id.detailsView);
final View headerView = findViewById(R.id.headerView);
final RelativeLayout container = (RelativeLayout)findViewById(R.id.containerRelativeLayout);
container.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
detailsView.animate().translationY(-detailsView.getY()).setDuration(500).withEndAction(new Runnable() {
#Override
public void run() {
Button additionalButton = new Button(MainActivity.this);
additionalButton.setText("Additional button");
RelativeLayout.LayoutParams additionalButtonParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
additionalButtonParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
additionalButton.setLayoutParams(additionalButtonParams);
container.addView(additionalButton);
}
}).start();
headerView.animate().translationY(detailsView.getHeight()).setDuration(500).start();
}
});
}
}
It works just as expected.
Have you tried to add your control(RouteBreakDownLayout) without animation? Does it work? It can be something like control is actually adding, but it's out of the viewport, etc. - so far, I can just guessing.
I create a view which inflates from RelativeLayout and contains some ImageView with an onClick listener on them.
However, it doesn't work, I tried to show a Toast without success.
I misunderstood something about View maybe.
This is my code:
(a fragment contains the view in his XML)
public class Timeline extends RelativeLayout {
private Context context;
private ImageView imageViewFirstStep;
private ImageView imageViewSecondStep;
private ImageView imageViewThirdStep;
private ImageView imageViewEndStep;
private View timelineView;
private int viewWidth;
private RelativeLayout relativeLayout;
private Drawable drawableFirstStep;
private Drawable drawableSecondStep;
private Drawable drawableThirdStep;
private Drawable drawableEndStep;
private RelativeLayout.LayoutParams layoutParamsStep;
private ProcessActivity activity;
public Timeline(Context context) {
super(context);
activity = (ProcessActivity) context;
init();
}
public Timeline(Context context, AttributeSet attrs){
super(context, attrs);
activity = (ProcessActivity) context;
init();
}
public Timeline(Context context, AttributeSet attrs, int defStyle){
super(context, attrs, defStyle);
activity = (ProcessActivity) context;
init();
}
public void init() {
inflate(getContext(), R.layout.timeline, this);
this.context = getContext();
this.imageViewFirstStep = (ImageView) findViewById(R.id.timeline_first_step);
this.imageViewSecondStep = (ImageView) findViewById(R.id.timeline_second_step);
this.imageViewThirdStep = (ImageView) findViewById(R.id.timeline_third_step);
this.imageViewEndStep = (ImageView) findViewById(R.id.timeline_end_step);
this.timelineView = (View) findViewById(R.id.timeline_timeline);
this.relativeLayout = (RelativeLayout) findViewById(R.id.timeline);
}
public void setTimelineImages(int firstStep, int secondStep,
int thirdStep, int endStep){
viewWidth = timelineView.getWidth();
drawableFirstStep = context.getResources().getDrawable(firstStep);
drawableSecondStep = context.getResources().getDrawable(secondStep);
drawableThirdStep = context.getResources().getDrawable(thirdStep);
drawableEndStep = context.getResources().getDrawable(endStep);
imageViewFirstStep.setImageDrawable(drawableFirstStep);
imageViewSecondStep.setImageDrawable(drawableSecondStep);
imageViewThirdStep.setImageDrawable(drawableThirdStep);
imageViewEndStep.setImageDrawable(drawableEndStep);
imageViewSecondStep.setPadding(viewWidth / 3, 0, 0, 0);
imageViewThirdStep.setPadding((viewWidth / 3) * 2, 0, 0, 0);
imageViewEndStep.setPadding(viewWidth, 0, 0, 0);
imageViewFirstStep.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
AtelierFragment atelierFragment = new AtelierFragment();
activity.showTest(atelierFragment);
/*AtelierFragment atelierFragment = (AtelierFragment) activity.getFragmentManager().findFragmentById(R.id.container);
FragmentTransaction fragmentTransaction =
activity.getFragmentManager().beginTransaction().replace(R.id.container, atelierFragment);
fragmentTransaction.commit();*/
Toast.makeText(v.getContext(), "test", Toast.LENGTH_LONG).show();
}
});
imageViewSecondStep.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
}
});
imageViewThirdStep.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
}
});
imageViewEndStep.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
}
});
}
/*
* set le texte affiché dans les images de la timeline en fonction des string passés en paramètre
* */
public void setTimelineTextView(String Step, TextView textViewStep, int position){
textViewStep = new TextView(context);
textViewStep.setText(Step);
Typeface face = Typeface.createFromAsset(context.getAssets(),
"fonts/TradeGothic-BoldCondTwenty.otf");
textViewStep.setTypeface(face);
}
The XML of my view :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/timeline">
<View
android:id="#+id/timeline_timeline"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_centerVertical="true"
android:layout_marginLeft="25px"
android:layout_marginRight="25px"
android:background="#color/hypred_menu_bleu_clair"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:id="#+id/timeline_first_step"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:id="#+id/timeline_second_step"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:id="#+id/timeline_third_step"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:id="#+id/timeline_end_step"/>
</RelativeLayout>
The XML of my fragment :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="100"
android:background="#color/hypred_blanc">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="15"></LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="70"
android:orientation="vertical"
android:weightSum="100">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="30"
android:weightSum="100"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="20"></LinearLayout>
<com.ylly.hypred.process.view.Timeline
android:id="#+id/fragment_organe_timeline"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="60">
</com.ylly.hypred.process.view.Timeline>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="20"></LinearLayout>
</LinearLayout>
<com.ylly.hypred.custom.MyTextView
android:id="#+id/fragment_atelier_choix_atelier_text_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:gravity="center"
android:text="#string/choix_equipement"
android:textSize="21dp"
android:textColor="#color/hypred_bleu"
android:layout_marginBottom="5dp"
custom:font_name="Arial-Bold.ttf"
android:background="#drawable/gradient"
android:layout_weight="5"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="65"
android:weightSum="100"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="10"></LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="80"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="60"
android:weightSum="100"
android:orientation="vertical"
android:background="#drawable/right_border">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="50"
android:orientation="horizontal"
android:weightSum="100">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="25">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/image_view_ligne_1_groupe_1"
android:src="#drawable/hypred_organe_groupe_1"
android:scaleType="fitCenter"
android:adjustViewBounds="true"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="75">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/image_view_ligne_1_groupe_2"
android:src="#drawable/hypred_organe_groupe_3"
android:scaleType="fitCenter"
android:adjustViewBounds="true"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="50"
android:weightSum="100"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="50">
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/image_view_ligne_2_groupe_1"
android:src="#drawable/hypred_organe_groupe_2"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="25">
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/image_view_ligne_2_groupe_2"
android:src="#drawable/hypred_organe_groupe_1"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="25">
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/image_view_ligne_2_groupe_3"
android:src="#drawable/hypred_organe_groupe_1"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="40"
android:weightSum="100"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="50"
android:weightSum="100"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="50"
android:weightSum="100"
android:orientation="vertical"
android:layout_gravity="center">
<ImageView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="80"
android:id="#+id/fragment_organe_circle_one"
android:layout_gravity="center"/>
<com.ylly.hypred.custom.MyTextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="20"
android:id="#+id/fragment_organe_text_view_circle_one"
android:textColor="#color/hypred_gris"
custom:font_name="Arial-Bold.ttf"
android:layout_gravity="center"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="50"
android:weightSum="100"
android:orientation="vertical"
android:layout_gravity="center">
<ImageView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:id="#+id/fragment_organe_circle_two"
android:layout_weight="80"
android:layout_gravity="center"/>
<com.ylly.hypred.custom.MyTextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="20"
android:id="#+id/fragment_organe_text_view_circle_two"
android:textColor="#color/hypred_gris"
custom:font_name="Arial-Bold.ttf"
android:layout_gravity="center"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="50"
android:weightSum="100"
android:orientation="horizontal"
android:layout_gravity="center">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="50"
android:weightSum="100"
android:orientation="vertical"
android:layout_gravity="center">
<ImageView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:id="#+id/fragment_organe_circle_three"
android:layout_weight="80"
android:layout_gravity="center"/>
<com.ylly.hypred.custom.MyTextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="20"
android:id="#+id/fragment_organe_text_view_circle_three"
android:textColor="#color/hypred_gris"
custom:font_name="Arial-Bold.ttf"
android:layout_gravity="center"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="50"
android:weightSum="100"
android:orientation="vertical"
android:layout_gravity="center">
<ImageView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:id="#+id/fragment_organe_circle_four"
android:layout_weight="80"
android:layout_gravity="center"/>
<com.ylly.hypred.custom.MyTextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="20"
android:id="#+id/fragment_organe_text_view_circle_four"
android:textColor="#color/hypred_gris"
custom:font_name="Arial-Bold.ttf"
android:layout_gravity="center"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="10"></LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="15"></LinearLayout>
</LinearLayout>
Thanks in advance and have a good day :)