FrameLayout or LinearLayout
I'm trying to put my switch button with text next to the ImageView.
Also, there should be a couple of another TextViews above the Switch and next to the same ImageView.
Firstly, I tried putting Switch in a FrameLayout and then moved it to the right so there would be left space for ImageView on the left. But in a result I cannot put ImageView there. ImageView is a part of parent LinearLayout.
Preview:
And code:
<ImageView
android:id="@+id/event_image"
android:layout_width="125dp"
android:layout_height="120dp"
android:layout_gravity="start"
android:scaleType="fitXY" />
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:background="@color/ToggleColor"
android:gravity="end"
android:orientation="vertical">
<Switch
android:id="@+id/switch1"
android:layout_width="276dp"
android:layout_height="50dp"
android:layout_gravity="bottom"
android:text="Recieve emails about upcoming events at this club."
android:textColor="@color/white"
android:textSize="14dp"
android:textStyle="normal" />
</FrameLayout>
Then, I got a rid of FrameLayout and put ImageLayout and Switch to the separate LinearLayout.
UPDATED.
I added another linearLayout inside. Looks much closer to goal but still not perfect with borders.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/event_image"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_gravity="start"
android:scaleType="fitXY" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp">
<TextView
android:id="@+id/event_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Event Name"
android:textColor="@color/white" />
<TextView
android:id="@+id/club_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Club Name"
android:textColor="@color/white" />
<TextView
android:id="@+id/date_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Date"
android:textColor="@color/white"
android:paddingBottom="11dp"/>
<Switch
android:onClick="switch_handler"
android:id="@+id/switch1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginLeft="5dp"
android:background="@color/ToggleColor"
android:paddingLeft="10dp"
android:text="Recieve emails about upcoming events at this club."
android:textColor="@color/white"
android:textSize="14dp"
android:textStyle="normal" />
</LinearLayout>
</LinearLayout>
I want this switch element be right next to the black border on the bottom and next to the right border of the phone.
android xml android-layout android-framelayout
add a comment |
I'm trying to put my switch button with text next to the ImageView.
Also, there should be a couple of another TextViews above the Switch and next to the same ImageView.
Firstly, I tried putting Switch in a FrameLayout and then moved it to the right so there would be left space for ImageView on the left. But in a result I cannot put ImageView there. ImageView is a part of parent LinearLayout.
Preview:
And code:
<ImageView
android:id="@+id/event_image"
android:layout_width="125dp"
android:layout_height="120dp"
android:layout_gravity="start"
android:scaleType="fitXY" />
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:background="@color/ToggleColor"
android:gravity="end"
android:orientation="vertical">
<Switch
android:id="@+id/switch1"
android:layout_width="276dp"
android:layout_height="50dp"
android:layout_gravity="bottom"
android:text="Recieve emails about upcoming events at this club."
android:textColor="@color/white"
android:textSize="14dp"
android:textStyle="normal" />
</FrameLayout>
Then, I got a rid of FrameLayout and put ImageLayout and Switch to the separate LinearLayout.
UPDATED.
I added another linearLayout inside. Looks much closer to goal but still not perfect with borders.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/event_image"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_gravity="start"
android:scaleType="fitXY" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp">
<TextView
android:id="@+id/event_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Event Name"
android:textColor="@color/white" />
<TextView
android:id="@+id/club_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Club Name"
android:textColor="@color/white" />
<TextView
android:id="@+id/date_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Date"
android:textColor="@color/white"
android:paddingBottom="11dp"/>
<Switch
android:onClick="switch_handler"
android:id="@+id/switch1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginLeft="5dp"
android:background="@color/ToggleColor"
android:paddingLeft="10dp"
android:text="Recieve emails about upcoming events at this club."
android:textColor="@color/white"
android:textSize="14dp"
android:textStyle="normal" />
</LinearLayout>
</LinearLayout>
I want this switch element be right next to the black border on the bottom and next to the right border of the phone.
android xml android-layout android-framelayout
1
Use ConstraintLayout instead
– Archie G. Quiñones
Jan 3 at 2:08
add a comment |
I'm trying to put my switch button with text next to the ImageView.
Also, there should be a couple of another TextViews above the Switch and next to the same ImageView.
Firstly, I tried putting Switch in a FrameLayout and then moved it to the right so there would be left space for ImageView on the left. But in a result I cannot put ImageView there. ImageView is a part of parent LinearLayout.
Preview:
And code:
<ImageView
android:id="@+id/event_image"
android:layout_width="125dp"
android:layout_height="120dp"
android:layout_gravity="start"
android:scaleType="fitXY" />
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:background="@color/ToggleColor"
android:gravity="end"
android:orientation="vertical">
<Switch
android:id="@+id/switch1"
android:layout_width="276dp"
android:layout_height="50dp"
android:layout_gravity="bottom"
android:text="Recieve emails about upcoming events at this club."
android:textColor="@color/white"
android:textSize="14dp"
android:textStyle="normal" />
</FrameLayout>
Then, I got a rid of FrameLayout and put ImageLayout and Switch to the separate LinearLayout.
UPDATED.
I added another linearLayout inside. Looks much closer to goal but still not perfect with borders.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/event_image"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_gravity="start"
android:scaleType="fitXY" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp">
<TextView
android:id="@+id/event_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Event Name"
android:textColor="@color/white" />
<TextView
android:id="@+id/club_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Club Name"
android:textColor="@color/white" />
<TextView
android:id="@+id/date_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Date"
android:textColor="@color/white"
android:paddingBottom="11dp"/>
<Switch
android:onClick="switch_handler"
android:id="@+id/switch1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginLeft="5dp"
android:background="@color/ToggleColor"
android:paddingLeft="10dp"
android:text="Recieve emails about upcoming events at this club."
android:textColor="@color/white"
android:textSize="14dp"
android:textStyle="normal" />
</LinearLayout>
</LinearLayout>
I want this switch element be right next to the black border on the bottom and next to the right border of the phone.
android xml android-layout android-framelayout
I'm trying to put my switch button with text next to the ImageView.
Also, there should be a couple of another TextViews above the Switch and next to the same ImageView.
Firstly, I tried putting Switch in a FrameLayout and then moved it to the right so there would be left space for ImageView on the left. But in a result I cannot put ImageView there. ImageView is a part of parent LinearLayout.
Preview:
And code:
<ImageView
android:id="@+id/event_image"
android:layout_width="125dp"
android:layout_height="120dp"
android:layout_gravity="start"
android:scaleType="fitXY" />
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:background="@color/ToggleColor"
android:gravity="end"
android:orientation="vertical">
<Switch
android:id="@+id/switch1"
android:layout_width="276dp"
android:layout_height="50dp"
android:layout_gravity="bottom"
android:text="Recieve emails about upcoming events at this club."
android:textColor="@color/white"
android:textSize="14dp"
android:textStyle="normal" />
</FrameLayout>
Then, I got a rid of FrameLayout and put ImageLayout and Switch to the separate LinearLayout.
UPDATED.
I added another linearLayout inside. Looks much closer to goal but still not perfect with borders.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/event_image"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_gravity="start"
android:scaleType="fitXY" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp">
<TextView
android:id="@+id/event_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Event Name"
android:textColor="@color/white" />
<TextView
android:id="@+id/club_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Club Name"
android:textColor="@color/white" />
<TextView
android:id="@+id/date_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Date"
android:textColor="@color/white"
android:paddingBottom="11dp"/>
<Switch
android:onClick="switch_handler"
android:id="@+id/switch1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginLeft="5dp"
android:background="@color/ToggleColor"
android:paddingLeft="10dp"
android:text="Recieve emails about upcoming events at this club."
android:textColor="@color/white"
android:textSize="14dp"
android:textStyle="normal" />
</LinearLayout>
</LinearLayout>
I want this switch element be right next to the black border on the bottom and next to the right border of the phone.
android xml android-layout android-framelayout
android xml android-layout android-framelayout
edited Jan 3 at 1:49
fnklstn
asked Jan 2 at 23:47
fnklstnfnklstn
204
204
1
Use ConstraintLayout instead
– Archie G. Quiñones
Jan 3 at 2:08
add a comment |
1
Use ConstraintLayout instead
– Archie G. Quiñones
Jan 3 at 2:08
1
1
Use ConstraintLayout instead
– Archie G. Quiñones
Jan 3 at 2:08
Use ConstraintLayout instead
– Archie G. Quiñones
Jan 3 at 2:08
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54014657%2fframelayout-or-linearlayout%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54014657%2fframelayout-or-linearlayout%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Use ConstraintLayout instead
– Archie G. Quiñones
Jan 3 at 2:08