How can I make two containers in a layout that I have created? The idea is to try to do something similar to what is highlighted in the following image.
And try to insert something similar in the topLinearLayout of my code
In those boxes I will insert the most profitable value with a green fund and the box that accompanies it with a red fund will show the least profitable value
CODE: 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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:background="@color/background">
<LinearLayout
android:id="@+id/saldoLinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/saldoTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/saldo"
android:textColor="@color/letra"
android:textSize="24sp"
android:textAlignment="center"/>
</LinearLayout>
<LinearLayout
android:id="@+id/topLinearLayout"
android:layout_width="match_parent"
android:layout_height="125dp"
android:layout_below="@+id/saldoLinearLayout"
android:orientation="horizontal">
</LinearLayout>
<LinearLayout
android:id="@+id/midTableLayout"
android:layout_width="match_parent"
android:layout_height="450dp"
android:layout_below="@+id/topLinearLayout"
android:orientation="vertical">
<ListView
android:id="@+id/lvListaDeBotones"
android:layout_height="match_parent"
android:layout_width="match_parent"/>
</LinearLayout>
<LinearLayout
android:id="@+id/menuLinearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/midTableLayout"
android:orientation="horizontal"
android:weightSum="3">
<Button
android:id="@+id/homeButton"
style="@style/Widget.AppCompat.Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Home" />
<Button
android:id="@+id/noticiasButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Noticias"
tools:ignore="ButtonStyle" />
<Button
android:id="@+id/estadoButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Estado"
tools:ignore="ButtonStyle" />
</LinearLayout>
</RelativeLayout>
JAVA:
public class MainActivity extends AppCompatActivity {
static final String[] TITULOS_BTN =
new String[] { "IBEX 35", "AENA", "BANCO SABADELL", "BANCO SANTANDER",
"CAIXABANK", "GAS NATURAL", "FERROVIAL", "IBERDROLA", "TELEFONICA",
"AMAZON", "MICROSOFT CORPORATION", "APPLE", "NASDAQ", "ORO", "PETROLEO"};
public ListView lvListaDeBotones;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
lvListaDeBotones = (ListView)findViewById(R.id.lvListaDeBotones);
MyAdapter mAdapter = new MyAdapter(this, TITULOS_BTN);
lvListaDeBotones.setAdapter(mAdapter);
lvListaDeBotones.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// Aquí puedes capturar en on Click de la vista que se crea en general.
}
});
}
}