I just created an Activity to show some product informations and this Activity has a Collapsing Toolbar. I wanted to load an image by Picasso as soon as the Activity opens.
Here is the current code :
public class ProductActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_product);
Product p = (Product) getIntent().getExtras().getSerializable("product");
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setTitle(p.getProductName());
TextView name = (TextView) findViewById(R.id.product_name);
TextView type = (TextView) findViewById(R.id.product_type);
TextView description = (TextView) findViewById(R.id.product_description);
TextView ingredients = (TextView) findViewById(R.id.product_ingredients);
TextView price = (TextView) findViewById(R.id.product_price);
ImageView thumbnail = (ImageView) findViewById(R.id.product_thumbnail);
name.setText(p.getProductName());
type.setText(p.getProductType().getDisplayName());
description.setText(p.getProductDescription());
ingredients.setText("Non disponible");
price.setText(p.getProductPrice().length>1 ? "À partir de "+p.getProductPrice()[0].toString()+"€" : p.getProductPrice()[0].toString()+"€");
Picasso.with(this).load(p.getProductThumbnailURL()).fit().into(thumbnail);
Picasso.with(this).load(p.getProductThumbnailURL()).fit().into((ImageView)findViewById(R.id.test), new Callback() {
#Override
public void onSuccess() {
}
#Override
public void onError() {
Toast.makeText(ProductActivity.this, "Impossible de charger l'image !", Toast.LENGTH_SHORT).show();
}
});
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
if(item.getItemId()==android.R.id.home)finish();
return super.onOptionsItemSelected(item);
}
}
And here is a screen of the Activity (don't take care of the design xD)
ProductActivity
Any idea ? :p
Here is the XML file of the ProductActivity :
<android.support.design.widget.CoordinatorLayout
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="com.slama.hotpizza77.ProductActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="250dp"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">
<ImageView
android:id="#+id/product_thumbnail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax"
android:contentDescription="#string/product_thumbnail_string" />
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:layout_scrollFlags="scroll|enterAlwaysCollapsed"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
app:layoutManager="LinearLayoutManager"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="0dp">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:id="#+id/product_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="product_name"
style="#style/TextAppearance.AppCompat.Large"
tools:ignore="HardcodedText" />
<TextView
android:id="#+id/product_type"
style="#style/TextAppearance.AppCompat.Medium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="product_type"
android:textAppearance="#style/TextAppearance.AppCompat.Button"
tools:ignore="HardcodedText" />
<TextView
style="#style/TextAppearance.AppCompat.Body1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Description :"
android:textSize="18sp"
tools:ignore="HardcodedText" />
<TextView
android:id="#+id/product_description"
style="#style/TextAppearance.AppCompat.Small"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="product_description"
android:textSize="16sp"
tools:ignore="HardcodedText" />
<TextView
style="#style/TextAppearance.AppCompat.Body1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Ingrédients :"
android:textSize="18sp"
tools:ignore="HardcodedText" />
<TextView
android:id="#+id/product_ingredients"
style="#style/TextAppearance.AppCompat.Small"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="product_ingredients"
android:textSize="16sp"
tools:ignore="HardcodedText" />
<LinearLayout
android:layout_marginTop="16dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="#drawable/ic_product_pork"/>
<TextView
android:layout_marginLeft="8dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Contient de la viande issue de porc !"
style="#style/TextAppearance.AppCompat.Body2"/>
</LinearLayout>
<LinearLayout
android:layout_marginTop="8dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="#drawable/ic_product_notforkid"/>
<TextView
android:layout_marginLeft="8dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Ne convient pas aux enfants !"
style="#style/TextAppearance.AppCompat.Body2"/>
</LinearLayout>
<TextView
android:id="#+id/product_price"
android:layout_marginTop="16dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="product_price"
style="#style/Widget.AppCompat.Button.Colored"
tools:ignore="HardcodedText" />
<ImageView
android:id="#+id/test"
android:layout_width="match_parent"
android:layout_height="200dp"/>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
Instead of wrap_content for your product_thumbnail ImageView height use match_parent or a fixed size.
Hope this helps
Related
I know this is common to ask but I really confused about how can I apply onClickListener to my navigationDrawer items, I have two items which is edit profile and Logout I just want to Toast or print if one of them is selected, Is there anyone can help me with this, I've already search on the internet , yet there's no OnClickListener I've found, need help
I think there's missing on my MainActivity which is the onCreate()
OnCreate() MainActivity
setContentView(R.layout.dashboard_main);
DrawerLayout drawerLayout = findViewById(R.id.drawerlayout);
NavigationView navigationView = (NavigationView) findViewById(R.id.navigationview);
sidemenu.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:checkableBehavior = "single">
<item android:id="#+id/editProfile"
android:icon="#drawable/history"
android:title="Edit Profile"/>
<item android:id="#+id/logout_menu"
android:icon="#drawable/logout"
android:title="Logout"/>
</group>
sidebar_header
<?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="180dp"
android:background="#color/dashboard_item_1"
android:orientation="vertical"
android:gravity="center"
android:padding="20dp"
>
<de.hdodenhof.circleimageview.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/profile_image"
android:layout_width="80dp"
android:layout_height="80dp"
android:src="#drawable/user_logo"
app:civ_border_width="2dp"
app:civ_border_color="#FFFFFF"/>
<TextView
android:id="#+id/fullName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="User"
android:textColor="#FFFFFF"
android:textSize="15sp"
android:textStyle="bold"/>
<TextView
android:id="#+id/idNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Id no."
android:textColor="#FFFFFF"
android:textSize="12sp"/>
</LinearLayout>
dashboard_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout
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/background"
android:id="#+id/drawerlayout"
tools:context=".MainActivity">
<com.google.android.material.navigation.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/navigationview"
app:headerLayout="#layout/sidebar_header"
app:menu="#menu/sidemenu"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_gravity="start"/>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/background"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:title="Toolbars"
app:titleTextColor="#FFFFFF"
app:titleMarginStart = "10dp"
android:layout_marginBottom="5dp"
tools:ignore="MissingConstraints"/>
<View
android:id="#+id/viewHeaderBackground"
android:layout_width="match_parent"
android:layout_height="#dimen/_125sdp"
android:background="#color/primary"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:id="#+id/textTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/_16sdp"
android:layout_marginLeft="#dimen/_16sdp"
android:layout_marginTop="#dimen/_16sdp"
android:text="Dashboard"
android:textColor="#color/white"
android:textSize="#dimen/_20ssp"
android:textStyle="bold"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"/>
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="#dimen/_26sdp"
android:layout_height="#dimen/_26sdp"
android:layout_marginEnd="#dimen/_16sdp"
android:layout_marginRight="#dimen/_16sdp"
android:src="#drawable/user_logo"
app:layout_constraintBottom_toBottomOf="#id/textTitle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="#id/textTitle"
/>
<com.google.android.material.card.MaterialCardView
android:id="#+id/cardHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/_16sdp"
android:layout_marginEnd="#dimen/_16sdp"
app:cardBackgroundColor="#color/card_background"
app:cardCornerRadius="#dimen/_16sdp"
app:layout_constraintBottom_toBottomOf="#id/viewHeaderBackground"
app:layout_constraintTop_toBottomOf="#id/viewHeaderBackground">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="#dimen/_14sdp">
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Overview"
android:textColor="#color/primary_text"
android:textSize="#dimen/_14ssp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<ImageButton
android:id="#+id/textViews"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:background="#android:color/transparent"
android:layout_marginTop="#dimen/_8sdp"
android:scaleType="fitCenter"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<LinearLayout
android:id="#+id/layoutClients"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/_8sdp"
android:gravity="center"
android:orientation="vertical"
app:layout_constraintEnd_toStartOf="#id/layoutImpacted"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/textViews">
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="#dimen/_28sdp"
android:layout_height="#dimen/_28sdp"
android:src="#drawable/ic_clients"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/_4sdp"
android:text="Pending"
android:textColor="#color/secondary_text"
android:textSize="#dimen/_10ssp"/>
<TextView
android:id="#+id/txtPending"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/_4sdp"
android:text="0"
android:textColor="#color/primary_text"
android:textSize="#dimen/_16ssp"/>
</LinearLayout>
<LinearLayout
android:id="#+id/layoutImpacted"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/_8sdp"
android:gravity="center"
android:orientation="vertical"
app:layout_constraintEnd_toStartOf="#id/layoutFollowing"
app:layout_constraintStart_toEndOf="#id/layoutClients"
app:layout_constraintTop_toBottomOf="#id/textViews">
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="#dimen/_28sdp"
android:layout_height="#dimen/_28sdp"
android:src="#drawable/ic_impacted"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/_4sdp"
android:text="Approved"
android:textColor="#color/secondary_text"
android:textSize="#dimen/_10ssp"/>
<TextView
android:id="#+id/txtApproved"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/_4sdp"
android:text="0"
android:textColor="#color/primary_text"
android:textSize="#dimen/_16ssp"/>
</LinearLayout>
<LinearLayout
android:id="#+id/layoutFollowing"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/_8sdp"
android:gravity="center"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#id/layoutImpacted"
app:layout_constraintTop_toBottomOf="#id/textViews">
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="#dimen/_28sdp"
android:layout_height="#dimen/_28sdp"
android:src="#drawable/ic_following"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/_4sdp"
android:text="Records"
android:textColor="#color/secondary_text"
android:textSize="#dimen/_10ssp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/_4sdp"
android:text="0"
android:textColor="#color/primary_text"
android:textSize="#dimen/_16ssp"/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:clipToPadding="false"
android:overScrollMode="never"
android:padding="#dimen/_16sdp"
android:scrollbars="none"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="#id/cardHeader">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="#layout/dashboard_item_1"/>
<include layout="#layout/dashboard_item_2"/>
<include layout="#layout/dashboard_item_3"/>
<include layout="#layout/dashboard_item_4"/>
</LinearLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.drawerlayout.widget.DrawerLayout >
Updated I tried the code below but when I click the items it will automatically hide back the sidebar and there are no Toast pops
navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
#Override
public boolean onNavigationItemSelected(MenuItem item) {
if (item.getItemId() == R.id.editProfile)
{
Toast.makeText(getApplicationContext(),"profile",Toast.LENGTH_SHORT).show();
}
else if (item.getItemId() == R.id.logout_menu)
{
Toast.makeText(getApplicationContext(),"logout",Toast.LENGTH_SHORT).show();
}
return false;
}
});
First you need to implement NavigationView.OnNavigationItemSelectedListener interface on your Activity.
then on your onCreate() method type
navigationView.setNavigationItemSelectedListener(this); after this override the method onNavigationItemSelected.
here you can use this sample code.
#Override
public boolean onNavigationItemSelected(#NonNull MenuItem item) {
if (item.getItemId() == R.id.editProfile)
{
//edit your profile
}
else if (item.getItemId() == R.id.logout)
{
//log out
}
return false;
}
I want to dynamically change textviews height to fit cells in other linearlayout.
I tried to make this in this way:
#Override
public void onBindViewHolder(#NonNull final MyViewHolder holder, final int position) {
holder.numberCage.setText(cages.get(position).getNumberCage());
holder.eggsDescription.setText(cages.get(position).getEggsDescription());
holder.eggsFrom.setText(cages.get(position).getNumberCageFrom());
if(cages.get(position).getBasicEggs().toString().equals("true"))
holder.basicEggs.setText("Tak");
else
holder.basicEggs.setText("Nie");
holder.dateEggs.setText(cages.get(position).getDateEggs());
holder.description.setText(cages.get(position).getDescription());
holder.pigeonsInside.setText(cages.get(position).getPigeonsInside());
holder.numberCageTitle.setHeight(holder.numberCage.getHeight());
holder.eggsDescriptionTitle.setHeight(holder.eggsDescription.getHeight());
holder.eggsFromTitle.setHeight(holder.eggsFrom.getHeight());
holder.basicEggsTitle.setHeight(holder.basicEggs.getHeight());
holder.dateEggsTitle.setHeight(holder.dateEggs.getHeight());
holder.descriptionTitle.setHeight(holder.description.getHeight());
holder.pigeonsInsideTitle.setHeight(holder.pigeonsInside.getHeight());
}
class MyViewHolder extends RecyclerView.ViewHolder{
TextView numberCage,pigeonsInside,description, dateEggs, basicEggs, eggsFrom, eggsDescription, numberCageTitle, pigeonsInsideTitle, descriptionTitle, dateEggsTitle, basicEggsTitle, eggsFromTitle, eggsDescriptionTitle;
LinearLayout linearLayout, linearLayoutLeft, linearLayoutRight;
public MyViewHolder(View view){
super(view);
numberCage = view.findViewById(R.id.numberCage);
pigeonsInside = view.findViewById(R.id.pigeonsInside);
description = view.findViewById(R.id.description);
dateEggs = view.findViewById(R.id.dateEggs);
basicEggs = view.findViewById(R.id.basicEggs);
eggsFrom = view.findViewById(R.id.eggsFrom);
eggsDescription = view.findViewById(R.id.eggsDescription);
numberCageTitle = view.findViewById(R.id.numberCageTitle);
pigeonsInsideTitle = view.findViewById(R.id.pigeonsInsideTitle);
descriptionTitle = view.findViewById(R.id.descriptionTitle);
dateEggsTitle = view.findViewById(R.id.dateEggsTitle);
basicEggsTitle = view.findViewById(R.id.basicEggsTitle);
eggsFromTitle = view.findViewById(R.id.eggsFromTitle);
eggsDescriptionTitle = view.findViewById(R.id.eggsDescriptionTitle);
linearLayout = view.findViewById(R.id.linearLayout);
}
}
I have good results but my problem is that I have to scroll down and scroll up my list to "load" this heights, I don't know how to tell this so I show you screenshot.
left table is not showing
After scroll down: left table after scroll
This is my content xml:
<LinearLayout 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="wrap_content"
android:baselineAligned="true"
android:weightSum="2"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context=".CageList"
tools:showIn="#layout/activity_cage_list"
android:divider="#android:color/black"
android:dividerPadding="1dip"
android:showDividers="end"
android:id="#+id/linearLayout"
>
<LinearLayout
android:id="#+id/linearLayoutLeft"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.25"
android:orientation="vertical">
<TextView
android:id="#+id/numberCageTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Numer klatki:"
android:textAppearance="#style/TextAppearance.AppCompat.Body1" />
<TextView
android:id="#+id/pigeonsInsideTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Gołębie w klatce:"
android:textAppearance="#style/TextAppearance.AppCompat.Body1" />
<TextView
android:id="#+id/descriptionTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Opis klatki:"
android:textAppearance="#style/TextAppearance.AppCompat.Body1" />
<TextView
android:id="#+id/dateEggsTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Data złożenia jaj:"
android:textAppearance="#style/TextAppearance.AppCompat.Body1" />
<TextView
android:id="#+id/basicEggsTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Jajka macierzyste?"
android:textAppearance="#style/TextAppearance.AppCompat.Body1" />
<TextView
android:id="#+id/eggsFromTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Jajka przełożone skąd? (klatka)"
android:textAppearance="#style/TextAppearance.AppCompat.Body1" />
<TextView
android:id="#+id/eggsDescriptionTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Opis do jajek:"
android:textAppearance="#style/TextAppearance.AppCompat.Body1" />
<View
android:layout_width="200dp"
android:layout_height="1dp"
android:background="#color/colorPrimary"
/>
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayoutRight"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.75"
android:orientation="vertical">
<TextView
android:id="#+id/numberCage"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/pigeonsInside"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/description"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/dateEggs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/basicEggs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/eggsFrom"
android:layout_width="match_parent"
android:layout_height="35.65dp" />
<TextView
android:id="#+id/eggsDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/colorPrimary"/>
</LinearLayout>
</LinearLayout>
create another file named sub_layout.xml which will have below code :-
<LinearLayout
android:id="#+id/linear"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1"
android:orientation="horizontal">
<TextView
android:id="#+id/txtTitleStatic"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.45"
android:text="Jajka przełożone skąd? (klatka)"
android:textAppearance="#style/TextAppearance.AppCompat.Body1" />
<TextView
android:id="#+id/txtTitle"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".55" />
</LinearLayout>
and then use below code to include in main layout (You Content XML File):-
<include
android:id="#+id/numberCageLayout"
layout="#layout/sub_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<include
android:id="#+id/pigeonsInsideLayout"
layout="#layout/sub_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<include
android:id="#+id/descriptionLayout"
layout="#layout/sub_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
Now in your Java File get their definition like :-
View numberCageLayout = findViewById(R.id.numberCageLayout);
View pigeonsInsideLayout = findViewById(R.id.pigeonsInsideLayout);
View descriptionLayout = findViewById(R.id.descriptionLayout);
TextView numberCageStatic =numberCageLayout.findViewById(R.id.txtTitleStatic);
TextView numberCage =numberCageLayout.findViewById(R.id.txtTitle);
TextView pigeonsInsideStatic =pigeonsInsideLayout.findViewById(R.id.txtTitleStatic);
TextView pigeonsInside =pigeonsInsideLayout.findViewById(R.id.txtTitle);
Now like this you don't have to worry about cell height.
I have two radiobutton groups that need to be initialized when loading the screen, so I used this code:
mVisibilityPublic.setChecked(true);
But when I load the screen I get the following (first is the wrong behavior, second is the expected one):
I've tried with all these:
mVisibilityPublic.setSelected(true);
mVisibilityPublic.performClick();
mVisibilityPublic.setActivated(true);
mVisibilityPublic.invalidate();
mVisibilityPublic.requestLayout();
But I get the same result.
<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="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:orientation="vertical"
android:padding="#dimen/form_vertical_spacing"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context=".createevent.CreateEventActivity">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="#string/create_event_privacy"
android:textColor="#color/colorAccent"
android:textStyle="bold"
/>
<RadioGroup
android:id="#+id/create_visibility_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="16dp"
android:paddingTop="16dp">
<RadioButton
android:id="#+id/createevent_visibility_public"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/create_event_public_event"/>
<RadioButton
android:id="#+id/createevent_visibility_private"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/create_event_private_event"/>
<RadioButton
android:id="#+id/createevent_visibility_ppv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/create_event_ppv"/>
</RadioGroup>
<LinearLayout
android:id="#+id/ppv_panel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:text="#string/create_event_ppv_section"
android:textColor="#color/colorAccent"
android:textStyle="bold"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.design.widget.TextInputLayout
android:id="#+id/ppv.currency.layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<com.myapp.ui.AutoCompleteCombo
android:id="#+id/ppv.currency"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/create_event_ppv_currency">
</com.myapp.ui.AutoCompleteCombo>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/ppv.price.layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_weight="1">
<android.support.design.widget.TextInputEditText
android:id="#+id/ppv.price"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/create_event_ppv_price"
android:imeOptions="actionDone"
android:inputType="numberDecimal"
android:maxLines="1"
/>
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<RadioGroup
android:id="#+id/ppv_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="16dp"
android:paddingTop="16dp">
<RadioButton
android:id="#+id/ppv_all"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/create_event_ppv_allcountries"/>
<RadioButton
android:id="#+id/ppv_allexcept"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/create_event_ppv_except"/>
<RadioButton
android:id="#+id/ppv_only"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/create_event_ppv_some"/>
</RadioGroup>
<com.myapp.countries.CountriesMultiCombo
android:id="#+id/create.ppv.countrylist"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
/>
</LinearLayout>
<View
android:id="#+id/separator"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#+id/general_info"
android:layout_marginBottom="#dimen/activity_vertical_margin"
android:layout_marginLeft="-32dp"
android:layout_marginRight="-32dp"
android:layout_marginTop="#dimen/activity_vertical_margin"
android:background="#color/colorDivider"
/>
<LinearLayout
android:id="#+id/geoblock_panel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="visible">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:text="#string/geo_blocking_settings_title"
android:textColor="#color/colorAccent"
android:textStyle="bold"
/>
<RadioGroup
android:id="#+id/geo_radiogroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="16dp"
android:paddingTop="16dp">
<RadioButton
android:id="#+id/geo_none"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/geo_none"/>
<RadioButton
android:id="#+id/geo_blockonly"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/geo_block_only"/>
<RadioButton
android:id="#+id/geo_blockexcept"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/geo_block_all_except"/>
</RadioGroup>
<com.myapp.createevent.countries.CountriesMultiCombo
android:id="#+id/create.geo.countrylist"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
/>
</LinearLayout> <Button
android:id="#+id/test_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="CLICK ME"/>
</LinearLayout>
</ScrollView>
Note that if I select the option manually (like I did with the second example in the image) I get the proper result. Its only if I do it programmatically that its missing the inner circle.
public class TestFragment extends Fragment {
private Unbinder mUnbinder;
#BindView(R.id.createevent_visibility_public)
RadioButton mVisibilityPublic;
#Nullable
#Override
public View onCreateView(LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState) {
View inflate = inflater.inflate(R.layout.fragment_advanced_opts, container, false);
mUnbinder = ButterKnife.bind(this, inflate);
return inflate;
}
public static TestFragment newInstance(int tvId, int eventId) {
TestFragment testFragment = new TestFragment();
Bundle args = new Bundle();
args.putInt(TV_ARGUMENT, tvId);
args.putInt(EVENTID_ARGUMENT, eventId);
testFragment.setArguments(args);
return testFragment;
}
#Override
public void onViewCreated(View view, #Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mVisibilityPublic.setChecked(true);
}
}
I am currently coding a small app, and I trying to integrate the "material design" of Google.
I use in my app to github's floating Action menu button library and I have some worries.
Unlike the single button, the menu generates a larger view. I put my menu down the fab header. But the code does not seem good.
I wish to bring up the menu fab down my header properly (I use the CollapsingToolbarLayout). And the menu follows the scroll. But i'm stuck here.
My question is how to put the menu fab between my header and my cardviews, and how to scroll the fab menu with my collapsing toolbar.
Thank you in advance.
My layout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:id="#+id/drawerlayout1">
<android.support.design.widget.CoordinatorLayout
android:id="#+id/coordinatorlayout"
android:layout_width="fill_parent"
android:layout_height="match_parent"
app:expandedTitleMarginStart="70dp">
<android.support.design.widget.AppBarLayout
android:theme="#style/AppTheme.AppBarOverlay"
android:layout_width="fill_parent"
android:id="#+id/appbarlayout"
android:layout_height="230dp">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/CollapsingToolbarLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="#+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="#drawable/console_font"/>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:title="test"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="#style/AppTheme.PopupOverlay"
android:clickable="true"
app:layout_collapseMode="pin"
android:minHeight="?attr/actionBarSize"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="top"
android:layout_weight=".1" >
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/card_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<LinearLayout
android:layout_alignParentBottom="true"
android:id="#+id/fragmentContainer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="10dp">
<TextView
android:textColor="#android:color/holo_blue_light"
android:layout_marginTop="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Console"
android:id="#+id/textView5" />
<Spinner
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/spinner"
android:layout_gravity="center_horizontal" />
<View style="#style/Divider"/>
<TextView
android:textColor="#android:color/holo_blue_light"
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Etat"
android:id="#+id/textView2" />
<Spinner
android:layout_marginTop="10dp"
android:entries="#array/etat"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/spinner2" />
<View style="#style/Divider"/>
<TextView
android:textColor="#android:color/holo_blue_light"
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Région"
android:id="#+id/textView6" />
<Spinner
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="#array/localisation"
android:id="#+id/spinner3" />
<View style="#style/Divider"/>
<TextView
android:textColor="#android:color/holo_blue_light"
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Contenu"
android:id="#+id/textView3" />
<Spinner
android:layout_marginTop="10dp"
android:entries="#array/contenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/spinner4"
android:layout_gravity="center_horizontal" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:layout_marginBottom="10dp"
android:layout_weight=".1" >
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/card_view2"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/fragmentContainer2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_marginLeft="10dp">
<EditText
android:textColor="#android:color/holo_blue_light"
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/editText"
android:layout_marginBottom="10dp"
android:hint="Ecrire un commentaire" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<com.github.clans.fab.FloatingActionMenu
android:id="#+id/menu_down"
android:layout_width="match_parent"
android:layout_height="37dp"
android:layout_alignParentRight="true"
android:layout_marginTop="185dp"
android:paddingRight="10dp"
android:paddingTop="10dp"
android:paddingLeft="10dp"
android:elevation="6dp"
fab:menu_labels_ellipsize="end"
fab:menu_labels_singleLine="true"
app:layout_anchor="#id/image"
app:layout_anchorGravity="bottom|right|end"
fab:menu_openDirection="down">
<com.github.clans.fab.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fab:fab_size="mini"
fab:fab_label="Menu item 1" />
<com.github.clans.fab.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fab:fab_size="mini"
fab:fab_label="Menu item 2" />
</com.github.clans.fab.FloatingActionMenu>
</android.support.design.widget.CoordinatorLayout>
My code fragment:
public class ConsoleSql extends AppCompatActivity {
private JvAdapter mDbHelper;
TextView Titre;
Spinner spin_console;
Spinner spin_etat;
Spinner spin_region;
Spinner spin_contenu;
EditText commentaire;
String value;
CollapsingToolbarLayout collapsingToolbarLayout;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.customconsole);
Toolbar myToolbar = (Toolbar) findViewById(toolbar);
collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.CollapsingToolbarLayout1);
myToolbar.setTitle("Ajout console");
setSupportActionBar(myToolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_close);
spin_console = (Spinner) findViewById(R.id.spinner);
spin_etat = (Spinner) findViewById(R.id.spinner2);
spin_region = (Spinner) findViewById(R.id.spinner3);
spin_contenu = (Spinner) findViewById(R.id.spinner4);
commentaire = (EditText) findViewById(R.id.editText);
Bundle extras = getIntent().getExtras();
if (extras != null) {
value = extras.getString("constructeur");
int arryid = this.getResources().getIdentifier(value, "array", this.getPackageName());
collapsingToolbarLayout.setTitle("Console "+value);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, arryid, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spin_console.setAdapter(adapter);
}
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.consolemenu, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_save) {
mDbHelper = new JvAdapter(this);
mDbHelper.open();
//do some stuffs...
return true;
}
return super.onOptionsItemSelected(item);
}
Change you layout_anchor to "appbarlayout" instead of "image"
<com.github.clans.fab.FloatingActionMenu
android:id="#+id/menu_down"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="6dp"
fab:menu_labels_ellipsize="end"
fab:menu_labels_singleLine="true"
app:layout_anchor="#id/appbarlayout"
app:layout_anchorGravity="bottom|end"
fab:menu_openDirection="down">
</com.github.clans.fab.FloatingActionMenu>
I'm trying to inflate a list of views in a LinarLayout directly in the onCreate() method from the activity. However, I'm having a problem somewhere in the code but I really can't see it, I'm turning around this problem for two days, I'm going crazy !
The problem is that when I run the activity, the linear layout is completely empty, there is only the title.
Here is the important part of the code, KeyItems activity :
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.keyitems_layout);
initializer();
ll = (LinearLayout) findViewById(R.id.ll);
LayoutInflater inflater = LayoutInflater.from(this);
for (int i = 0; i < list.size(); i++) {
View view = inflater.inflate(R.layout.keyitem_temp, ll, false);
final TextView ind = (TextView) view.findViewById(R.id.ind);
final TextView item = (TextView) view.findViewById(R.id.item);
ind.setText(list.get(i).get("id"));
item.setText(list.get(i).get("item"));
ll.addView(view);
}
}
Here is the keyitems_layout :
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#color/black" >
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#color/black">
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp" />
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="#string/key_items"
android:textSize="36sp"
android:textColor="#color/white" />
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="4dp" />
<LinearLayout android:id="#+id/ll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="32dp"
android:layout_marginRight="32dp"
android:orientation="vertical"
android:background="#color/white" >
</LinearLayout>
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/white"
android:text="caca"
android:padding="32dp" />
</LinearLayout>
</ScrollView>
And finally, my keyitem_temp.xml which I'm inflating :
<?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="wrap_content"
android:background="#color/black"
android:padding="4dp"
android:orientation="horizontal" >
<TextView android:id="#+id/ind"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:textSize="18sp"
android:textColor="#color/blue" />
<TextView android:id="#+id/item"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:textSize="18sp"
android:textColor="#color/white"/>
</LinearLayout>
I have an other activity called ItemsActivity which is the same code with some little differences and it works. Any suggestion? Thanks in advance.
Try using wrap_content for all of your heights except the initial ScrollView:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#color/black" >
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#color/black">
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp" />
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="#string/key_items"
android:textSize="36sp"
android:textColor="#color/white" />
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="4dp" />
<LinearLayout android:id="#+id/ll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:layout_marginRight="32dp"
android:orientation="vertical"
android:background="#color/white" >
</LinearLayout>
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/white"
android:text="caca"
android:padding="32dp" />
</LinearLayout>
</ScrollView>
and:
<?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="wrap_content"
android:background="#color/black"
android:padding="4dp"
android:orientation="horizontal" >
<TextView android:id="#+id/ind"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:textSize="18sp"
android:textColor="#color/blue" />
<TextView android:id="#+id/item"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:textSize="18sp"
android:textColor="#color/white"/>
</LinearLayout>