在Android中为图标设置Imageview大小

时间:2016-01-28 12:24:02

标签: android

我是Android的新手。在我的应用程序中,我使用的是动作栏图标的图像视图,其布局是包装内容。我也为每个DPI设置了所有resp大小的图像。但是当我测试它时,图像看起来太小了在更大尺寸的手机。我也试过给图像视图提供大小,但是在某些手机中它看起来很大而在其他手机中看起来很小。我在XML设置中缺少什么?

2 个答案:

答案 0 :(得分:0)

根据设备大小,使用configuration qualifiers创建不同的可绘制目录。

 Sub Mail_workbook_Outlook_1()

      Dim OutApp As Object
      Dim OutMail As Object

      Set OutApp = CreateObject("Outlook.Application")
      Set OutMail = OutApp.CreateItem(0)

      On Error Resume Next

      Dim DatePassed(100) As Variant
      Dim i As Integer
      For i = 6 To 13
           If Cells(i, 1) < Date Then
             DatePassed(i - 6) = Cells(i, 2)
           End If
      Next i

      '=================================================
      'New Section

      Dim DataPassedElementReference As Long
      Dim DataPassedString As String

      DataPassedString = ""

      'Using 100 as this is waht you used to define the array
      For DataPassedElementReference = 1 To 100

           DataPassedString = DataPassedString & DataPassed(DataPassedElementReference) & " "

      Next DataPassedElementReference
      '=================================================

      With OutMail
          .To = "Joerge@Johnson.com"
          .CC = "James@Johnson.com"
          .BCC = ""
          .Subject = "Unmanaged Clients"
          'Note the difference here
          '.Body = DataPassed
          .Body = DataPassedString
          .Attachments.Add ActiveWorkbook.FullName
          .Send
      End With
      On Error GoTo 0

      Set OutMail = Nothing
      Set OutApp = Nothing

 End Sub

答案 1 :(得分:0)

如果您已经拥有不同分辨率的不同照片,并且想要根据屏幕尺寸调整ImageView的大小,则应将ImageView放置在布局中并为其分配权重。无论屏幕尺寸如何,它们都会根据您指定的重量占据空间。

    <LinearLayout
        android:layout_width = "match_parent"
        android:layout_height = "match_parent"
        android:weightSum = "2"
        android:orientation = "horizontal"
        >
        <ImageView
             android:layout_width="0dp"
             android:layout_height="wrap_content"
             android:layout_weight = "1" />
        <ImageView
             android:layout_width="0dp"
             android:layout_height="wrap_content"
             android:layout_weight = "1" />

    </LinearLayout>

只是为了一个想法,这个代码将平均分割两个ImageViews,无论屏幕大小。