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.



enter image description here



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>









share|improve this question























  • 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














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.



enter image description here



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>









share|improve this question























  • 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












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.



enter image description here



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>









share|improve this question















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.



enter image description here



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>






android android-togglebutton






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 10 at 21:16









0X0nosugar

6,71631742




6,71631742










asked Nov 10 at 20:53









Seaky Luo

62




62











  • 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










  • @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

















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
);



);













 

draft saved


draft discarded


















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















 

draft saved


draft discarded















































 


draft saved


draft discarded














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





















































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







Popular posts from this blog

Top Tejano songwriter Luis Silva dead of heart attack at 64

ReactJS Fetched API data displays live - need Data displayed static

政党