有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何调整图标(图像按钮),使其不会放大?

下面是一个链接,指向我的主屏幕当前的样子:

https://imgur.com/a/WKZ5nHG

这里有一个链接,指向我想要的外观(这是我的IOS版本!):

https://imgur.com/a/IfEw2Ek

我目前在文件夹中有所有正确大小的版本。我希望主屏幕看起来像我的iOS版本。我想知道这是我在代码中修复的东西,还是我用sketch/illustrator修复的东西。请让我知道,我将非常感激。提前谢谢

以下是我的主要活动。xml文件如下所示:

<LinearLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
xmlns:tools="http://schemas.安卓.com/tools"
安卓:layout_width="match_parent"
安卓:layout_height="match_parent"
xmlns:app="http://schemas.安卓.com/apk/res-auto"
安卓:orientation="vertical"
tools:context="com.example.leoconnelly.connexus.MainActivity">

<LinearLayout
    安卓:id="@+id/ll_learn"
    安卓:layout_width="match_parent"
    安卓:layout_height="0dp"
    安卓:layout_gravity="center_vertical"
    安卓:layout_weight="1">

    <ImageButton
        安卓:id="@+id/learn"
        安卓:layout_width="match_parent"
        安卓:scaleType="centerCrop"
        安卓:src="@mipmap/learn_layer"
        安卓:layout_height="match_parent"
        安卓:layout_gravity="center_vertical"
        安卓:padding="0dp"
        安卓:layout_weight="1"
        安卓:text="@string/learn"
        安卓:textSize="22sp"
       />

<LinearLayout
    安卓:id="@+id/ll_find_care"
    安卓:layout_width="match_parent"
    安卓:layout_height="0dp"
    安卓:layout_weight="1"
    安卓:layout_gravity="center_vertical">

    <ImageButton
        安卓:id="@+id/find_care_button"
        安卓:layout_width="match_parent"
        安卓:scaleType="centerCrop"
        安卓:src="@mipmap/find_care_layer"
        安卓:layout_height="match_parent"
        安卓:layout_gravity="center_vertical"
        安卓:padding="0dp"
        安卓:layout_weight="1"
        安卓:text="@string/learn"
        安卓:textSize="22sp" />

</LinearLayout>

<LinearLayout
    安卓:id="@+id/ll_talk_to_doctor"
    安卓:layout_width="match_parent"
    安卓:layout_height="0dp"
    安卓:layout_weight="1"
    安卓:layout_gravity="center_vertical">

    <ImageButton
        安卓:id="@+id/TalkToADocButton"

        安卓:layout_width="match_parent"
        安卓:scaleType="centerCrop"
        安卓:src="@mipmap/talk_doc_layer"
        安卓:layout_height="match_parent"
        安卓:layout_gravity="center_vertical"
        安卓:padding="0dp"
        安卓:layout_weight="1"
        安卓:textSize="22sp" />


</LinearLayout>

<LinearLayout
    安卓:id="@+id/ll_visit_website"
    安卓:layout_width="match_parent"
    安卓:layout_height="0dp"
    安卓:layout_weight="1"
    安卓:layout_gravity="center_vertical">

    <ImageButton
        安卓:id="@+id/VisitWeb"
        安卓:layout_width="match_parent"
        安卓:scaleType="centerCrop"

        安卓:src="@mipmap/visit_web_layer"

        安卓:layout_height="match_parent"
        安卓:layout_gravity="center_vertical"
        安卓:padding="0dp"
        安卓:layout_weight="1"
        安卓:textSize="22sp" />

</LinearLayout>


共 (1) 个答案

  1. # 1 楼答案

    你误解了线性布局,你只需要一个嵌套层:

    • 线性布局
      • ImageView
      • ImageView

    那么对于您的问题,填充可能会有所帮助,这可能更像是触发实际渲染的scaleType。试试fitCenter,告诉我发生了什么