I saw so many people ask the same question in here, but I still cannot find the reason why my scrollview doesn't work.
Here is my Layout
<?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:id="#+id/activity_upload"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp"
android:fillViewport="true"
tools:context="com.example.daniw.traekle.upload">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="#+id/tv_itemName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Item Name"
android:textColor="#000000"
android:textStyle="bold"
android:textSize="20sp"
android:layout_marginBottom="5dp"/>
<EditText
android:id="#+id/et_itemTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Title"
android:layout_marginBottom="5dp"
android:textColor="#000000"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="Book ISBN(option)"
android:id="#+id/tv_bISBN"
android:textSize="20sp"
android:textStyle="bold"
android:textColor="#000000" />
<EditText
android:id="#+id/et_ISBN"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:textColor="#000000"
android:text="test"/>
<TextView
android:id="#+id/tv_itemPrice"
android:text="Price"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="#000000"
android:layout_marginBottom="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:id="#+id/et_itemPrice"
android:text="Test"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"/>
<TextView
android:id="#+id/tv_itemDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Item Description"
android:textSize="20sp"
android:textColor="#000000"
android:textStyle="bold"
android:layout_marginBottom="5dp"/>
<android.support.design.widget.TextInputLayout
android:id="#+id/inputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:counterEnabled="true"
app:counterMaxLength="600"
app:counterOverflowTextAppearance="#style/MyOverflowText">
<EditText
android:id="#+id/et_itemDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:text="Test"
android:maxLength="600"
android:textColor="#000000"/>
</android.support.design.widget.TextInputLayout>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:text="Choose Image"
android:id="#+id/b_chooseImage"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="#+id/itemImage"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Post Item"
android:id="#+id/bPost"/>
</LinearLayout>
</ScrollView>
That is so weird, because I finished other layout use the scrollview it's work fine, but in this activity the scrollview doesn't even show in preview.
There no scroll
You have your LinearLayout height set to fill_parent which is deprecated but is the same thing is match_parent instead your LinearLayout height should be set to wrap_content.
The reason is that your LinearLayout has the same exact height as the ScrollView so there is no need to scroll. If you set it to wrap_content the LinearLayout can have a height larger then the ScrollView which will scroll to show what is outside of ScrollViews bounds
Try this:
<?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:id="#+id/activity_upload"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp"
android:fillViewport="true"
tools:context="com.example.daniw.traekle.upload">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/tv_itemName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Item Name"
android:textColor="#000000"
android:textStyle="bold"
android:textSize="20sp"
android:layout_marginBottom="5dp"/>
<EditText
android:id="#+id/et_itemTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Title"
android:layout_marginBottom="5dp"
android:textColor="#000000"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="Book ISBN(option)"
android:id="#+id/tv_bISBN"
android:textSize="20sp"
android:textStyle="bold"
android:textColor="#000000" />
<EditText
android:id="#+id/et_ISBN"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:textColor="#000000"
android:text="test"/>
<TextView
android:id="#+id/tv_itemPrice"
android:text="Price"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="#000000"
android:layout_marginBottom="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:id="#+id/et_itemPrice"
android:text="Test"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"/>
<TextView
android:id="#+id/tv_itemDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Item Description"
android:textSize="20sp"
android:textColor="#000000"
android:textStyle="bold"
android:layout_marginBottom="5dp"/>
<android.support.design.widget.TextInputLayout
android:id="#+id/inputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:counterEnabled="true"
app:counterMaxLength="600"
app:counterOverflowTextAppearance="#style/MyOverflowText">
<EditText
android:id="#+id/et_itemDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:text="Test"
android:maxLength="600"
android:textColor="#000000"/>
</android.support.design.widget.TextInputLayout>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:text="Choose Image"
android:id="#+id/b_chooseImage"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_margin="5dp"
android:paddingBottom="16dp"
android:scaleType="fitXY"
android:id="#+id/itemImage"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Post Item"
android:id="#+id/bPost"/>
</LinearLayout>
</ScrollView>
Just realize how stupid am I , i finish fixed this problem.
<?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:id="#+id/activity_upload"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp"
android:fillViewport="true"
tools:context="com.example.daniw.traekle.upload">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:text="Choose Image"
android:id="#+id/b_chooseImage"/>
<ImageView
android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_margin="5dp"
android:layout_marginBottom="5dp"
android:paddingBottom="50dp"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:paddingTop="3dp"
android:scaleType="fitXY"
android:id="#+id/itemImage"/>
<TextView
android:id="#+id/tv_itemName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Item Name"
android:textColor="#000000"
android:textStyle="bold"
android:textSize="20sp"
android:layout_marginBottom="5dp"/>
<EditText
android:id="#+id/et_itemTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Title"
android:layout_marginBottom="5dp"
android:textColor="#000000"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="Book ISBN(option)"
android:id="#+id/tv_bISBN"
android:textSize="20sp"
android:textStyle="bold"
android:textColor="#000000" />
<EditText
android:id="#+id/et_ISBN"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:textColor="#000000"
android:text="test"/>
<TextView
android:id="#+id/tv_itemPrice"
android:text="Price"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="#000000"
android:layout_marginBottom="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:id="#+id/et_itemPrice"
android:text="Test"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"/>
<TextView
android:id="#+id/tv_itemDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Item Description"
android:textSize="20sp"
android:textColor="#000000"
android:textStyle="bold"
android:layout_marginBottom="5dp"/>
<android.support.design.widget.TextInputLayout
android:id="#+id/inputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:counterEnabled="true"
app:counterMaxLength="600"
app:counterOverflowTextAppearance="#style/MyOverflowText">
<EditText
android:id="#+id/et_itemDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:text="Test"
android:maxLength="600"
android:textColor="#000000"/>
</android.support.design.widget.TextInputLayout>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Post Item"
android:id="#+id/bPost"/>
</LinearLayout>
</ScrollView>
Now this layout working fine
Related
I want my one textbox to only wrap content till the beginning of the next textbox.
Screenshot now:
and how I want it:
I was thinking I could set the width but it wouldn't display correctly on different size screens, I want it to end there so I can have it ellipses if the content goes out of the area.
Please help!
Layout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
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:id="#+id/cardView_item_assesment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:clickable="true"
android:focusable="true"
app:cardCornerRadius="4dp"
app:cardElevation="4dp"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/textView_title"
android:layout_width="285dp"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginEnd="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginStart="5dp"
android:layout_marginTop="5dp"
android:ellipsize="end"
android:maxLines="1"
android:scrollHorizontally="true"
android:textColor="#color/colorPrimaryDark"
android:textSize="30sp"
tools:text="PlaceHolder" />
<TextView
android:id="#+id/textView_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:textColor="#color/colorPrimaryDark"
android:textSize="15sp"
android:layout_margin="5dp"
tools:text="2018/09/02" />
<TextView
android:id="#+id/textView_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView_date"
android:layout_alignParentEnd="true"
android:textColor="#color/colorPrimaryDark"
android:textSize="15sp"
android:layout_margin="5dp"
tools:text="09:00" />
<TextView
android:id="#+id/textView_total"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="#id/editText_achieved"
android:layout_below="#+id/textView_title"
android:textColor="#color/colorPrimaryDark"
android:layout_alignBaseline="#id/editText_achieved"
android:textSize="20sp"
android:layout_margin="5dp"
tools:text="Total: 100" />
<android.support.v7.widget.AppCompatEditText
android:id="#+id/editText_achieved"
android:layout_width="130dp"
android:layout_height="wrap_content"
android:layout_below="#+id/textView_title"
android:maxLines="1"
android:textColor="#color/colorPrimaryDark"
android:textSize="20sp"
tools:text="Result: 50" />
<TextView
android:id="#+id/textView_contribution"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView_total"
android:textColor="#color/colorPrimaryDark"
android:textSize="20sp"
android:layout_margin="5dp"
tools:text="Weight: 25%"/>
<TextView
android:id="#+id/txtID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="invisible" />
</RelativeLayout>
add:
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/textView_date"
and set width to wrap_content in your first TextView
<TextView
android:id="#+id/textView_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginEnd="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginStart="5dp"
android:layout_marginTop="5dp"
android:layout_toLeftOf="#+id/textView_date"
android:layout_alignParentLeft="true"
android:ellipsize="end"
android:maxLines="1"
android:scrollHorizontally="true"
android:textColor="#color/colorPrimaryDark"
android:textSize="30sp"
tools:text="PlaceHolder" />
result
Use LinearLayout for this...
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1"
android:padding="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="text"
android:layout_weight=".4"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="12/12/1212"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="9:00"/>
</LinearLayout>
</LinearLayout>
Result:
I am creating a form in which I have specified some EditText and some TextView . At last I have specified a Checkbox like this:
<CheckBox
android:id="#+id/sendAsSMS"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send As SMS"
android:checked="false"
android:textSize="16sp"
/>
But this checkbox is not getting displayed in the layout when the app is running. What is going wrong here.
My full layout.xml is :
<?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="com.schoolcounter.ui.activity.teacher.AddHomeworkActivity">
<LinearLayout
android:id="#+id/addHomeworkForm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<LinearLayout
android:id="#+id/selectClassLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/select_class"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:paddingRight="#dimen/text_padding"
android:paddingTop="#dimen/text_padding"
android:paddingBottom="#dimen/text_padding"
android:text="#string/select_class"
android:textAlignment="textEnd"
android:textColor="#color/colorPrimary"
android:textStyle="bold"
android:textSize="#dimen/text_size" />
<com.weiwangcn.betterspinner.library.material.MaterialBetterSpinner
android:id="#+id/select_class_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:hint="#string/select_class"
android:textAlignment="viewStart"
android:textColorHint="#color/colorHint"
android:textSize="#dimen/text_size" />
</LinearLayout>
<LinearLayout
android:id="#+id/selectSectionLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/select_section"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:paddingRight="#dimen/text_padding"
android:paddingTop="#dimen/text_padding"
android:paddingBottom="#dimen/text_padding"
android:text="#string/select_section"
android:textAlignment="textEnd"
android:textColor="#color/colorPrimary"
android:textSize="#dimen/text_size"
android:textStyle="bold"/>
<com.weiwangcn.betterspinner.library.material.MaterialBetterSpinner
android:id="#+id/select_section_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:hint="#string/select_section"
android:textAlignment="viewStart"
android:textColorHint="#color/colorHint"
android:textSize="#dimen/text_size"/>
</LinearLayout>
<LinearLayout
android:id="#+id/selectSubjectLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/select_subject"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:paddingRight="#dimen/text_padding"
android:paddingTop="#dimen/text_padding"
android:paddingBottom="#dimen/text_padding"
android:text="#string/select_subject"
android:textAlignment="textEnd"
android:textColor="#color/colorPrimary"
android:textSize="#dimen/text_size"
android:textStyle="bold"/>
<com.weiwangcn.betterspinner.library.material.MaterialBetterSpinner
android:id="#+id/select_subject_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:hint="#string/select_subject"
android:textAlignment="viewStart"
android:textColorHint="#color/colorHint"
android:textSize="#dimen/text_size"/>
</LinearLayout>
<LinearLayout
android:id="#+id/uploadedDateLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView_uploaded_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:paddingRight="#dimen/text_padding"
android:paddingTop="#dimen/text_padding"
android:paddingBottom="#dimen/text_padding"
android:text="#string/text_uploaded_date"
android:textAlignment="textEnd"
android:textColor="#color/colorPrimary"
android:textSize="#dimen/text_size"
android:textStyle="bold"/>
<EditText
android:id="#+id/editTextUploadedDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="#dimen/text_size"
android:focusable="false"
android:focusableInTouchMode="false"/>
</LinearLayout>
<LinearLayout
android:id="#+id/completionDateLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView_completion_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:paddingRight="#dimen/text_padding"
android:paddingTop="#dimen/text_padding"
android:paddingBottom="#dimen/text_padding"
android:text="#string/text_completion_date"
android:textAlignment="textEnd"
android:textColor="#color/colorPrimary"
android:textSize="#dimen/text_size"
android:textStyle="bold"/>
<EditText
android:id="#+id/editTextCompletionDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="#dimen/text_size"
android:focusable="false"
android:focusableInTouchMode="false"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/textView_Homework"
android:text="#string/text_homework"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="#dimen/text_padding"
android:textColor="#color/colorPrimary"
android:textSize="#dimen/text_size"
android:textStyle="bold"/>
<EditText
android:id="#+id/editTextHomeworkText"
android:layout_width="match_parent"
android:layout_height="74dp"
android:ems="10"
android:inputType="textMultiLine"
android:textSize="#dimen/text_size"/>
<CheckBox
android:id="#+id/sendAsSMS"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send As SMS"
android:checked="false"
android:textSize="16sp"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical"
android:weightSum="1">
<Button
android:id="#+id/uploadHomeworkButton"
style="#style/button_style_corners"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_marginBottom="16dp"
android:layout_marginTop="16dp"
android:text="#string/text_upload"
android:textAlignment="center"
android:textColor="#color/colorWhite" />
</LinearLayout>
</LinearLayout>
</ScrollView>
You have to change the width attribute value of EditText 'editTextHomeworkText' in
<TextView
android:id="#+id/textView_Homework"
android:text="#string/text_homework"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="#dimen/text_padding"
android:textColor="#color/colorPrimary"
android:textSize="#dimen/text_size"
android:textStyle="bold"/>
<EditText
android:id="#+id/editTextHomeworkText"
android:layout_width="match_parent"
android:layout_height="74dp"
android:ems="10"
android:inputType="textMultiLine"
android:textSize="#dimen/text_size"/>
<CheckBox
android:id="#+id/sendAsSMS"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send As SMS"
android:checked="false"
android:textSize="16sp"
/>
</LinearLayout>
Since you assigned the width value as 'match_parent' all the remaining space is covered by EditText only. Here either you can change the value to 'wrap_content' or do it like
android:layout_width="0dp"
android:layout_weight="1"
I am new to Android and working on a App and stuck here on ScrollView. I have tried width and height "match parent" but still not working. I am posting my code. I have wasted more than an hour on this. Thanks in advance.
Here is my 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:weightSum="1"
android:orientation="vertical">
<LinearLayout
android:id="#+id/linear_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.02"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="20dp"
android:text="Marketing"
android:textColor="#color/black"
android:textSize="25dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linear_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linear_header"
android:layout_weight="0.02"
android:background="#color/light_blue"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="15dp"
android:text="Register Here"
android:textColor="#color/white"
android:textSize="22dp"
android:textStyle="bold" />
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linear_register"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:layout_weight="0.04"
android:orientation="vertical">
<EditText
android:id="#+id/edit_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Name*"
android:inputType="text" />
<EditText
android:id="#+id/edit_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="Email*"
android:inputType="text" />
<EditText
android:id="#+id/edit_pswd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="Password*"
android:inputType="text" />
<EditText
android:id="#+id/edit_cnfrm_pswd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="Confirm Password*"
android:inputType="text" />
<Button
android:id="#+id/btn_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_marginTop="20dp"
android:background="#drawable/button_bg"
android:padding="15dp"
android:text="Register"
android:textStyle="bold" />
<TextView
android:id="#+id/txt_forgot_pswd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="Forgot/Reset Password"
android:textColor="#color/light_blue" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:weightSum="1"
android:layout_marginBottom="10dp"
android:orientation="horizontal">
<Button
android:id="#+id/btn_google"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="GOOGLE"
android:textColor="#color/white"
android:textStyle="bold"
android:textSize="15sp"
android:layout_marginRight="5dp"
android:background="#color/red"
android:layout_weight="0.5"/>
<Button
android:id="#+id/btn_facebook"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="FACEBOOK"
android:textColor="#color/white"
android:background="#color/fb_blue"
android:layout_marginLeft="5dp"
android:textStyle="bold"
android:textSize="15sp"
android:layout_weight="0.5"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
set lay out weight to scroll view like
<ScrollView
android:layout_weight="0.96"
android:layout_width="match_parent"
android:layout_height="wrap_content">
Hi in the below xml using drawable i was added frame.Now,for single one I am displaying personal information In the same way how to display multiple but title should be different.
How do that one any one can help me.
updated
<?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" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/frame1">
<RelativeLayout
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:background="#android:color/white">
<!-- This is the main content -->
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="280dp"
android:layout_margin="15dp"
android:background="#drawable/frame1"
android:orientation="vertical"
android:padding="20dp" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center|center_vertical"
android:background="#DFECEB"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginTop="20dp"
android:padding="5dp"
android:text="First Name:"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textSize="15sp"
android:textStyle="bold" />
<EditText
android:id="#+id/first_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:background="#drawable/rounded"
android:cursorVisible="true"
android:padding="5dp"
android:singleLine="true"
android:textColor="#000000" >
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginTop="10dp"
android:padding="5dp"
android:text="Last Name:"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="15sp"
android:textStyle="bold" />
<EditText
android:id="#+id/last_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:background="#drawable/rounded"
android:cursorVisible="true"
android:inputType="textPassword"
android:padding="5dp"
android:singleLine="true"
android:textColor="#000000" >
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginTop="10dp"
android:padding="5dp"
android:text="Email:"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="15sp"
android:textStyle="bold" />
<EditText
android:id="#+id/email"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:background="#drawable/rounded"
android:cursorVisible="true"
android:inputType="textPassword"
android:padding="5dp"
android:singleLine="true"
android:textColor="#000000" >
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginTop="10dp"
android:padding="5dp"
android:text="Mobile No."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="15sp"
android:textStyle="bold" />
<EditText
android:id="#+id/mobile_no"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:background="#drawable/rounded"
android:cursorVisible="true"
android:inputType="textPassword"
android:padding="5dp"
android:singleLine="true"
android:textColor="#000000" >
</EditText>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<!-- This is the title label -->
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
android:background="#android:color/white" android:padding="5dp"
android:text="Personal Information"
android:layout_marginLeft="30dp" android:textColor="#android:color/black" />
</RelativeLayout>
</FrameLayout>
</LinearLayout>
Am not 100% sure , what you are asking. If my understanding is correct, you want to wrap the frame . If so, try editing your Relative layouts height to Wrapcontent.
<RelativeLayout
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_margin="5dp" android:background="#drawable/frame1"
android:orientation="vertical" android:padding="5dp">
So I've completed an early version of my Android app and begun testing on various devices. I'm finding my nested LinearLayouts aren't sufficient for my purposes so I'm trying to convert the nested LinearLayouts to a RelativeLayout. Below is my starting point:
<?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="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
tools:context=".LoginActivity">
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="#drawable/backgroundhomescreen"
android:scaleType="fitXY" />
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="35dp">
<LinearLayout
android:orientation="vertical"
android:padding="10dp">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal"
android:paddingBottom="3dp"
android:layout_marginBottom="10dp">
<EditText
android:id="#+id/login_txt_Username"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#layout/textboxlogin"
android:hint="Username or Email"
android:inputType="textEmailAddress"
android:scrollbars="none"
android:textColor="#fff"
android:textColorHint="#ddd" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal"
android:paddingBottom="3dp"
android:paddingTop="3dp"
android:layout_marginBottom="10dp">
<EditText
android:id="#+id/login_txt_Password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#layout/textboxlogin"
android:hint="Password"
android:inputType="textPassword"
android:maxLines="1"
android:textColorHint="#ddd" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal"
android:paddingBottom="3dp"
android:paddingTop="3dp">
<Button
android:id="#+id/login_btn_submit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="SIGN IN"
android:textColor="#fff"
android:textSize="25dp"
android:textStyle="bold"
android:typeface="normal"
android:background="#layout/buttonsigninbackground" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal"
android:paddingBottom="10dp"
android:paddingTop="3dp">
<TextView
android:id="#+id/login_txt_or"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="- or -"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="25dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal"
android:paddingBottom="15dp"
android:paddingTop="3dp">
<Button
android:id="#+id/login_btn_navCreateAccount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#layout/buttoncreateaccountbackground"
android:text="CREATE AN ACCOUNT"
android:textColor="#fff"
android:textSize="25dp"
android:textStyle="bold"
android:typeface="normal" />
</LinearLayout>
</LinearLayout>
</TableLayout>
</RelativeLayout>
And here is where I've gotten so far but with some issues - even after following this tutorial - Visual Guide to RelativeLayout
<?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="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:context=".LoginActivity">
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="#drawable/backgroundhomescreen"
android:scaleType="fitXY" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<EditText
android:id="#+id/login_txt_Username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#layout/textboxlogin"
android:hint="Username"
android:layout_centerHorizontal="true"
android:inputType="textEmailAddress"
android:maxLines="1"
android:scrollbars="none"
android:textColor="#fff"
android:textColorHint="#ddd" />
<EditText
android:id="#+id/login_txt_Password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#layout/textboxlogin"
android:hint="Password"
android:layout_centerHorizontal="true"
android:inputType="textPassword"
android:maxLines="1"
android:scrollbars="none"
android:textColor="#fff"
android:textColorHint="#ddd"
android:layout_below="#id/login_txt_Username"
/>
<Button
android:id="#+id/login_btn_submit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:text="SIGN IN"
android:layout_centerHorizontal="true"
android:textColor="#fff"
android:textSize="25dp"
android:textStyle="bold"
android:typeface="normal"
android:background="#layout/buttonsigninbackground" />
<TextView
android:id="#+id/login_txt_or"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="- or -"
android:layout_centerHorizontal="true"
android:layout_above="#+id/login_btn_navCreateAccount"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="25dp"
android:textStyle="bold" />
<Button
android:id="#id/login_btn_navCreateAccount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#layout/buttoncreateaccountbackground"
android:text="CREATE AN ACCOUNT"
android:textColor="#fff"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:layout_marginBottom="25dp"
android:textSize="25dp"
android:textStyle="bold"
android:typeface="normal" />
</RelativeLayout>
</RelativeLayout>
Ultimately I need a relative layout that's bottom aligned so I can place other views just above the previous. In my second code sample above, textview 'login_txt_or' that references login_btn_navCreateAccount seems to be ignored.
Any clue to why this is? If it's of any use, I'm using Xamarin.Android 4.10.1 in Xamarin Studio.
This is what I ended up with
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/activity_login_relativeLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="#drawable/backgroundgameplaying"
android:scaleType="fitXY" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="bottom"
android:layout_marginBottom="45dp">
<TextView
android:id="#+id/login_tv_error"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="15dp"
android:textColor="#f00" />
<EditText
android:id="#+id/login_txt_Username"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="25dp"
android:background="#layout/textboxlogin"
android:hint="Username"
android:layout_centerHorizontal="true"
android:inputType="textEmailAddress"
android:maxLines="1"
android:scrollbars="none"
android:textColor="#fff"
android:textColorHint="#ddd"
android:layout_below="#id/login_tv_error" />
<EditText
android:id="#+id/login_txt_Password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="25dp"
android:background="#layout/textboxlogin"
android:hint="Password"
android:layout_centerHorizontal="true"
android:inputType="textPassword"
android:maxLines="1"
android:scrollbars="none"
android:textColor="#fff"
android:textColorHint="#ddd"
android:layout_below="#id/login_txt_Username" />
<Button
android:id="#+id/login_btn_submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/login_txt_Password"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="25dp"
android:textColor="#fff"
android:textSize="25dp"
android:textStyle="bold"
android:typeface="normal"
android:background="#layout/buttonsigninbackground"
android:text="SIGN IN" />
<TextView
android:id="#+id/loginTxtOr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/login_btn_submit"
android:layout_centerHorizontal="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_marginBottom="25dp"
android:textSize="25dp"
android:textStyle="bold|italic"
android:text="- or -" />
<Button
android:id="#+id/login_btn_navCreateAccount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_alignParentRight="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="25dp"
android:layout_below="#id/loginTxtOr"
android:background="#layout/buttoncreateaccountbackground"
android:textColor="#fff"
android:textSize="25dp"
android:textStyle="bold"
android:typeface="normal"
android:text="CREATE AN ACCOUNT" />
</RelativeLayout>
</RelativeLayout>