Questions tagged «android»

Android是Google的移动操作系统,用于对数字设备(智能手机,平板电脑,汽车,电视,Wear,Glass和IoT)进行编程或开发。对于与Android相关的主题,请使用特定于Android的标签,例如android-intent,android-activity,android-adapter等。对于与开发或编程无关但与Android框架相关的问题,请使用以下链接:https:// android.stackexchange.com。


11
ImageView缩放比例TOP_CROP
我有一个ImageView正在显示png的png,该png的纵横比比设备的纵横比大(垂直地说-表示它更长)。我想在保持宽高比,匹配父级的宽度以及将imageview固定到屏幕顶部的同时显示此内容。 我使用CENTER_CROP缩放比例类型时遇到的问题是,它将(可以理解)将缩放后的图像居中,而不是将图像视图的顶部边缘与顶部边缘对齐。 问题FIT_START在于图像将适合屏幕高度,而不适合宽度。 我已经解决了这个问题,方法是使用自定义ImageView并onDraw(Canvas)使用画布手动覆盖和处理此问题;这种方法的问题是:1)我担心可能有一个更简单的解决方案,2)super(AttributeSet)当堆具有3 mb可用空间时,尝试在构造函数中设置330kb的src img 时,在构造函数中调用时收到VM mem异常(堆大小为6 mb),无法找出原因。 任何想法/建议/解决方案都非常受欢迎:) 谢谢 ps:我认为一个解决方案可能是使用矩阵比例类型,然后自己做,但这似乎比我当前的解决方案相同或更多!


7
AAPT2编译失败:Android 3.0 Canary 1上无效的dimen
我正在使用适用于Android的Instant Apps。问题是我总是遇到编译工具的问题。是否还有其他人有此问题,并且能够找到任何解决方法。 我的环境: Android Studio 3.0 Canary 1 编译SDK:25 构建工具:“ 26.0.0 rc2” Gradle插件:3.0.0-alpha1 Gradle:尝试了gradle-4.0-milestone1和2 Java 1.8 / 1.7 操作系统:尝试Windows 10和Linux Ubuntu 16.4 LTS 错误: Error: java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.internal.aapt.AaptException: AAPT2 compile failed: aapt2 compile -o /home/simonp/Work/201705_InstantApp/InstantAppTest/feature/build/intermediates/res/merged/androidTest/debug /home/simonp/Work/201705_InstantApp/InstantAppTest/feature/build/intermediates/incremental/mergeDebugAndroidTestResources/merged.dir/values/values.xml Issues: - ERROR: /home/simonp/Work/201705_InstantApp/InstantAppTest/feature/build/intermediates/incremental/mergeDebugAndroidTestResources/merged.dir/values/values.xml:520 invalid dimen - ERROR: /home/simonp/Work/201705_InstantApp/InstantAppTest/feature/build/intermediates/incremental/mergeDebugAndroidTestResources/merged.dir/values/values.xml:521 invalid dimen - ERROR: /home/simonp/Work/201705_InstantApp/InstantAppTest/feature/build/intermediates/incremental/mergeDebugAndroidTestResources/merged.dir/values/values.xml:568 …


18
将Google Play服务版本添加到您的应用清单中?
我正在学习本教程:https : //developers.google.com/maps/documentation/android/start#overview 关于如何将Google Maps添加到Android SDK中的应用程序。 我似乎遇到的唯一问题是在此期间(我已做完其他所有操作而没有错误): Edit your application's AndroidManifest.xml file, and add the following declaration within the <application> element. This embeds the version of Google Play services that the app was compiled with. <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> The error is: No resources found that match the given name …

16
阻止WebView显示“网页不可用”
我有一个可以广泛使用WebView的应用程序。当此应用程序的用户没有Internet连接时,将显示一个页面,显示“网页不可用”和其他各种文字。有没有办法在我的WebView中不显示此通用文本?我想提供自己的错误处理。 private final Activity activity = this; private class MyWebViewClient extends WebViewClient public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { // I need to do something like this: activity.webView.wipeOutThePage(); activity.myCustomErrorHandling(); Toast.makeText(activity, description, Toast.LENGTH_LONG).show(); } } 我发现WebView-> clearView实际上并未清除视图。
88 java  android 

17
在跨平台的移动开发方面做了哪些工作?[关闭]
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案会得到事实,参考或专业知识的支持,但是这个问题可能会引起辩论,争论,民意测验或进一步的讨论。如果您认为此问题可以解决并且可以重新提出,请访问帮助中心以获取指导。 8年前关闭。 有什么证据充分的或者开源项目的目标iPhone,Blackberry和Android?是否还有其他更适合这种工作的平台?请注意,我特别询问的是客户端软件,而不是Web应用程序,尽管有关在多个移动平台上使用Web应用程序的困难的任何信息也很有趣。

9
ScrollView中的ViewPager无法滚动正确
我有一个“页面”,上面有许多组件,谁的内容长于设备的高度。很好,只需将所有布局(整个页面)放在内ScrollView,没问题。 组件之一是ViewPager。这可以正确渲染,但是对滑动/滑动的响应未正确执行,抖动,并且无法始终正常工作。它似乎与变得“混淆” ScrollView,因此仅当您沿精确的水平线猛扑时才可以100%使用。 如果删除ScrollView,则ViewPager响应完美。 我进行了搜索,没有发现这是已知的缺陷。其他人有没有经历过? 平台版本:1.6 兼容性库v4。 设备:HTC Incredible S 下面是一些示例代码供您测试,注释掉ScrollView以使其正常工作。 活动: package com.ss.activities; import com.ss.R; import android.app.Activity; import android.content.Context; import android.graphics.Color; import android.os.Bundle; import android.os.Parcelable; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.view.View; import android.widget.TextView; public class PagerInsideScollViewActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ViewPager vp …

4
ViewFlipper和ViewSwitcher有什么区别
他们俩都继承ViewAnimator。我知道ViewSwitcher仅允许两个视图,而ViewFlipper允许更多视图。但是ViewSwitcher,如果Android仅创建了ViewFlipper2个视图,为什么还要创建它呢?还有其他区别吗?在什么条件下使用一种优于另一种?
88 android 

9
RelativeLayout中心垂直
我想做一个列表行布局。此布局的最左侧是图像视图,紧挨着图像视图的是文本视图,最右侧是图像视图。我希望所有这些都垂直居中。 <RelativeLayout android:layout_width="fill_parent" android:layout_height="100dp" android:gravity="center_vertical" > <ImageView android:id="@+id/icon" android:layout_width="50dp" android:layout_height="50dp" android:layout_gravity="center_vertical" /> <TextView android:id="@+id/func_text" android:layout_toRightOf="@id/icon" android:layout_width="wrap_content" android:layout_height="100dp" android:layout_gravity="center_vertical" /> <ImageView android:layout_width="50dp" android:layout_height="50dp" android:layout_alignParentRight="true" android:layout_gravity="center_vertical" android:src="@drawable/arrow" /> </RelativeLayout> 我也尝试添加android:layout_centerVertical="true"到textview中,但是结果是textview与两个imageview底部对齐。我在android 4.2模拟器中尝试过这个。有人可以帮助我吗?

9
带有片段的导航栏
我有一个标签式动作条/ viewpager布局三个标签说一,乙,和Ç。在标签Ç标签(片段),我加入另一片段发言权片段d。与 DFragment f= new DFragment(); ft.add(android.R.id.content, f, ""); ft.remove(CFragment.this); ft.addToBackStack(null); ft.commit(); 我在DFragment的onResume中修改操作栏以添加按钮: ActionBar ab = getActivity().getActionBar(); ab.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); ab.setDisplayHomeAsUpEnabled(true); ab.setDisplayShowHomeEnabled(true); 现在在DFragment中,当我按硬件(电话)“后退”按钮时,我返回到原始的Tabbed(ABC)布局,并选择了CFragment。如何通过操作栏上按钮实现此功能?

5
如何为Google Map API V2设置默认位置和缩放级别?
当我的地图显示时,它总是从固定位置开始(在非洲附近)。 然后,我使用以下代码将地图居中放置到所需位置。 mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(loc.getLatitude(), loc.getLongitude()), 14.0f)); 我的问题是,我可以在地图显示之前设置默认位置和缩放级别吗? 因为我不希望用户一开始就看到动画。 谢谢。


7
如何在ListView中添加页脚?
我正在开发一个应用程序,在我的应用程序中,我正在使用Listview通过dom解析显示数据,我想在listview中添加页脚,当我单击页脚时,将更多的数据添加到列表视图中,我附加了图像,我想要这种设计并过程,请参考image1和imgae2。我在红色矩形中提到了页脚 Fig1-Footer之类的“更多新闻” 图2-在列表视图中添加了另外10条记录

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.