Distorted toggle button image
up vote
1
down vote
favorite
I have found several duplicate questions. I'm having exactly the same problem:
Android Studio | How do I scale the image in ToggleButton?
Android Toggle Button distorted view
However, their problems haven't been solved yet so I just want to ask a new question again. So the third one on the left is what the second is supposed to be.
The second button is a custom toggle button, the idea of which comes from here: Android: Create a toggle button with image and no text
And I place these buttons in a horizontal LinearLayout.

This is the xml of that part:
<LinearLayout
android:id="@+id/post_button_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:orientation="horizontal"
android:padding="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/post_content"
app:layout_constraintHorizontal_bias="0.807"
app:layout_constraintStart_toStartOf="@+id/post_content"
app:layout_constraintTop_toBottomOf="@+id/post_divider2">
<ImageButton
android:id="@+id/post_comment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@android:drawable/screen_background_light_transparent"
app:srcCompat="@drawable/ic_comment"
tools:layout_editor_absoluteX="37dp"
tools:layout_editor_absoluteY="500dp" />
<ToggleButton
android:id="@+id/toggleButton"
style="@style/CollectToggle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/ic_collect_toggle_bg"/>
<ImageButton
android:id="@+id/post_collect"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@android:drawable/screen_background_light_transparent"
app:srcCompat="@drawable/ic_collection"
tools:layout_editor_absoluteX="288dp"
tools:layout_editor_absoluteY="508dp" />
<ImageButton
android:id="@+id/post_share"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@android:drawable/screen_background_light_transparent"
app:srcCompat="@drawable/ic_share"
tools:layout_editor_absoluteX="104dp"
tools:layout_editor_absoluteY="508dp" />
</LinearLayout>
add a comment |
up vote
1
down vote
favorite
I have found several duplicate questions. I'm having exactly the same problem:
Android Studio | How do I scale the image in ToggleButton?
Android Toggle Button distorted view
However, their problems haven't been solved yet so I just want to ask a new question again. So the third one on the left is what the second is supposed to be.
The second button is a custom toggle button, the idea of which comes from here: Android: Create a toggle button with image and no text
And I place these buttons in a horizontal LinearLayout.

This is the xml of that part:
<LinearLayout
android:id="@+id/post_button_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:orientation="horizontal"
android:padding="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/post_content"
app:layout_constraintHorizontal_bias="0.807"
app:layout_constraintStart_toStartOf="@+id/post_content"
app:layout_constraintTop_toBottomOf="@+id/post_divider2">
<ImageButton
android:id="@+id/post_comment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@android:drawable/screen_background_light_transparent"
app:srcCompat="@drawable/ic_comment"
tools:layout_editor_absoluteX="37dp"
tools:layout_editor_absoluteY="500dp" />
<ToggleButton
android:id="@+id/toggleButton"
style="@style/CollectToggle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/ic_collect_toggle_bg"/>
<ImageButton
android:id="@+id/post_collect"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@android:drawable/screen_background_light_transparent"
app:srcCompat="@drawable/ic_collection"
tools:layout_editor_absoluteX="288dp"
tools:layout_editor_absoluteY="508dp" />
<ImageButton
android:id="@+id/post_share"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@android:drawable/screen_background_light_transparent"
app:srcCompat="@drawable/ic_share"
tools:layout_editor_absoluteX="104dp"
tools:layout_editor_absoluteY="508dp" />
</LinearLayout>
and what's that@style/CollectToggle??
– Martin Zeitler
Nov 10 at 21:45
@MartinZeitler Actually I just change the name of the style in the 3rd link from toggleButton to CollectToggle
– Seaky Luo
Nov 10 at 22:04
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have found several duplicate questions. I'm having exactly the same problem:
Android Studio | How do I scale the image in ToggleButton?
Android Toggle Button distorted view
However, their problems haven't been solved yet so I just want to ask a new question again. So the third one on the left is what the second is supposed to be.
The second button is a custom toggle button, the idea of which comes from here: Android: Create a toggle button with image and no text
And I place these buttons in a horizontal LinearLayout.

This is the xml of that part:
<LinearLayout
android:id="@+id/post_button_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:orientation="horizontal"
android:padding="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/post_content"
app:layout_constraintHorizontal_bias="0.807"
app:layout_constraintStart_toStartOf="@+id/post_content"
app:layout_constraintTop_toBottomOf="@+id/post_divider2">
<ImageButton
android:id="@+id/post_comment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@android:drawable/screen_background_light_transparent"
app:srcCompat="@drawable/ic_comment"
tools:layout_editor_absoluteX="37dp"
tools:layout_editor_absoluteY="500dp" />
<ToggleButton
android:id="@+id/toggleButton"
style="@style/CollectToggle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/ic_collect_toggle_bg"/>
<ImageButton
android:id="@+id/post_collect"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@android:drawable/screen_background_light_transparent"
app:srcCompat="@drawable/ic_collection"
tools:layout_editor_absoluteX="288dp"
tools:layout_editor_absoluteY="508dp" />
<ImageButton
android:id="@+id/post_share"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@android:drawable/screen_background_light_transparent"
app:srcCompat="@drawable/ic_share"
tools:layout_editor_absoluteX="104dp"
tools:layout_editor_absoluteY="508dp" />
</LinearLayout>
I have found several duplicate questions. I'm having exactly the same problem:
Android Studio | How do I scale the image in ToggleButton?
Android Toggle Button distorted view
However, their problems haven't been solved yet so I just want to ask a new question again. So the third one on the left is what the second is supposed to be.
The second button is a custom toggle button, the idea of which comes from here: Android: Create a toggle button with image and no text
And I place these buttons in a horizontal LinearLayout.

This is the xml of that part:
<LinearLayout
android:id="@+id/post_button_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:orientation="horizontal"
android:padding="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/post_content"
app:layout_constraintHorizontal_bias="0.807"
app:layout_constraintStart_toStartOf="@+id/post_content"
app:layout_constraintTop_toBottomOf="@+id/post_divider2">
<ImageButton
android:id="@+id/post_comment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@android:drawable/screen_background_light_transparent"
app:srcCompat="@drawable/ic_comment"
tools:layout_editor_absoluteX="37dp"
tools:layout_editor_absoluteY="500dp" />
<ToggleButton
android:id="@+id/toggleButton"
style="@style/CollectToggle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/ic_collect_toggle_bg"/>
<ImageButton
android:id="@+id/post_collect"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@android:drawable/screen_background_light_transparent"
app:srcCompat="@drawable/ic_collection"
tools:layout_editor_absoluteX="288dp"
tools:layout_editor_absoluteY="508dp" />
<ImageButton
android:id="@+id/post_share"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@android:drawable/screen_background_light_transparent"
app:srcCompat="@drawable/ic_share"
tools:layout_editor_absoluteX="104dp"
tools:layout_editor_absoluteY="508dp" />
</LinearLayout>
edited Nov 10 at 21:16
0X0nosugar
7,00131742
7,00131742
asked Nov 10 at 20:53
Seaky Luo
63
63
and what's that@style/CollectToggle??
– Martin Zeitler
Nov 10 at 21:45
@MartinZeitler Actually I just change the name of the style in the 3rd link from toggleButton to CollectToggle
– Seaky Luo
Nov 10 at 22:04
add a comment |
and what's that@style/CollectToggle??
– Martin Zeitler
Nov 10 at 21:45
@MartinZeitler Actually I just change the name of the style in the 3rd link from toggleButton to CollectToggle
– Seaky Luo
Nov 10 at 22:04
and what's that
@style/CollectToggle ??– Martin Zeitler
Nov 10 at 21:45
and what's that
@style/CollectToggle ??– Martin Zeitler
Nov 10 at 21:45
@MartinZeitler Actually I just change the name of the style in the 3rd link from toggleButton to CollectToggle
– Seaky Luo
Nov 10 at 22:04
@MartinZeitler Actually I just change the name of the style in the 3rd link from toggleButton to CollectToggle
– Seaky Luo
Nov 10 at 22:04
add a comment |
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',
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%2f53243305%2fdistorted-toggle-button-image%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
active
oldest
votes
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f53243305%2fdistorted-toggle-button-image%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
and what's that
@style/CollectToggle??– Martin Zeitler
Nov 10 at 21:45
@MartinZeitler Actually I just change the name of the style in the 3rd link from toggleButton to CollectToggle
– Seaky Luo
Nov 10 at 22:04