小编Mas*_*ari的帖子

ImageView周围不需要的填充

我需要在所有活动/视图中包含标题图形.带标题的文件名为header.xml:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent" 
  android:layout_height="wrap_content"
  android:background="#0000FF" 
  android:padding="0dip">

  <ImageView xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/header"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_margin="0dip"
    android:layout_marginTop="0dip"
    android:layout_marginBottom="0dip"
    android:padding="0dip"
    android:paddingTop="0dip"
    android:paddingBottom="0dip"
    android:layout_gravity="fill"
    android:background="#00FF00"
    />
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)

注意android:background="#00FF00"(绿色),它只是可视化的目的.

我将它们包含在我的视图中:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical"
  style="@style/white_background">

  <include layout="@layout/header" />
  (...)
Run Code Online (Sandbox Code Playgroud)

因此,当我实际尝试时,结果看起来像左图像,而不是它应该是什么样的(右):

注意绿色边框

(1)这 - 橙色 - 部分是图像/ ImageView
(2)不受欢迎的绿色边框.注意:通常,绿色区域是透明的 - 它只是绿色,因为我设置了background.

注意顶部图像周围的绿色边框; 它是ImageView的一部分,我无法弄清楚它为什么存在或我如何摆脱它.它将所有填充和边距设置为0(但是当我省略它们时结果是相同的).图像是480x64px jpeg*,我把它放在res/drawable中(不是在其中一个中drawable-Xdpi).

(*jpeg,因为我似乎偶然发现了旧的png伽玛问题 - 起初我通过使绿色边框与图片橙色相同来解决问题,并且颜色不匹配.)

我在我的htc desire/2.2/Build 2.33.163.1和模拟器上试了一下.我也向#android-dev中的某个人描述了这个问题.她可以重现这个问题,但也没有解释.构建目标是1.6.

更新@tehgoose:此代码产生完全相同的顶部+底部填充结果.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical"
  style="@style/white_background">

  <!-- <include layout="@layout/header" />  --> …
Run Code Online (Sandbox Code Playgroud)

user-interface android imageview

140
推荐指数
3
解决办法
7万
查看次数

.dex文件中的方法引用数不能超过64k API 17

我正在使用SugarORM Library构建一个应用程序但是当我尝试为API 17构建项目时(没有检查其他人)它显示了构建错误.

    Information:Gradle tasks [:app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAnimatedVectorDrawable2330Library UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72330Library UP-TO-DATE
:app:prepareComAndroidSupportCardviewV72330Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2330Library UP-TO-DATE
:app:prepareComAndroidSupportMediarouterV72300Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72330Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42330Library UP-TO-DATE
:app:prepareComAndroidSupportSupportVectorDrawable2330Library UP-TO-DATE
:app:prepareComAndroidVolleyVolley100Library UP-TO-DATE
:app:prepareComGithubSatyanSugar14Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServices840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAds840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAnalytics840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppindexing840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppinvite840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppstate840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAuth840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBase840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBasement840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesCast840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesDrive840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesFitness840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGames840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGcm840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesIdentity840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesLocation840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesMaps840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesMeasurement840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesNearby840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPanorama840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPlus840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesSafetynet840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesVision840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWallet840Library …
Run Code Online (Sandbox Code Playgroud)

android gradle android-gradle-plugin sugarorm android-multidex

122
推荐指数
10
解决办法
12万
查看次数

RuntimeException:无法实例化应用程序

当我运行我的应用程序时,每次我在logcat中获得以下异常时:

 04-14 09:29:53.965: W/dalvikvm(1020): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
    04-14 09:29:53.985: E/AndroidRuntime(1020): FATAL EXCEPTION: main
    04-14 09:29:53.985: E/AndroidRuntime(1020): java.lang.RuntimeException: Unable to instantiate application   android.app.Application: java.lang.NullPointerException
    04-14 09:29:53.985: E/AndroidRuntime(1020):     at android.app.LoadedApk.makeApplication(LoadedApk.java:482)
    04-14 09:29:53.985: E/AndroidRuntime(1020):     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3938)
    04-14 09:29:53.985: E/AndroidRuntime(1020):     at android.app.ActivityThread.access$1300(ActivityThread.java:123)
    04-14 09:29:53.985: E/AndroidRuntime(1020):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1185)
    04-14 09:29:53.985: E/AndroidRuntime(1020):     at android.os.Handler.dispatchMessage(Handler.java:99)
    04-14 09:29:53.985: E/AndroidRuntime(1020):     at android.os.Looper.loop(Looper.java:137)
    04-14 09:29:53.985: E/AndroidRuntime(1020):     at android.app.ActivityThread.main(ActivityThread.java:4424)
    04-14 09:29:53.985: E/AndroidRuntime(1020):     at java.lang.reflect.Method.invokeNative(Native Method)
    04-14 09:29:53.985: E/AndroidRuntime(1020):     at java.lang.reflect.Method.invoke(Method.java:511)
    04-14 09:29:53.985: E/AndroidRuntime(1020):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
    04-14 09:29:53.985: …
Run Code Online (Sandbox Code Playgroud)

android android-emulator android-intent

97
推荐指数
2
解决办法
7万
查看次数

%Like Spring JpaRepository中的%Query

我想写一个类似的查询,JpaRepository但它没有返回任何东西:

LIKE '%place%'- 没有用.

LIKE 'place' 工作得很好.

这是我的代码:

@Repository("registerUserRepository")
public interface RegisterUserRepository extends 
JpaRepository<Registration,Long>{

    @Query("Select c from Registration c where c.place like:place")
     List<Registration> findByPlaceContaining(@Param("place")String place);
}
Run Code Online (Sandbox Code Playgroud)

java jpa spring-data-jpa

89
推荐指数
7
解决办法
11万
查看次数

如何在适配器中启动Activity?

我有自定义适配器的ListActivity.在每个视图中,它可能有一些按钮,我需要在其中实现OnClickListener.我需要在适配器中实现OnClickListener.但是,我不知道如何调用函数如startActivity()或setResult().因为适配器不会扩展到Activity.

那么解决这个问题的最佳方法是什么?谢谢

java android adapter android-activity

67
推荐指数
4
解决办法
10万
查看次数

单击 fcm 通知而不是打开启动器活动时打开浏览器

我想将带有 FCM 的 url 发送到 android 应用程序。单击 FCM 通知而不是打开启动器活动时,是否可以打开浏览器?我知道可以使用覆盖onMessageReceived()方法,但我不想这样做。我检查了click_action有效负载中的参数,但正如 Firebase 所说:

如果指定,则当用户单击通知时将启动具有匹配意图过滤器的活动。

我尝试click_action在 firebase cloudMessaging 面板中添加CustomData ,如下所示:

在此处输入图片说明

但它不起作用并打开应用程序。

我使用邮递员为此目的发送通知并添加click_action到这样的notification对象:

在此处输入图片说明

通知发送到我的设备,但当点击它时,什么也没发生!!!

重要提示:我的 apk 在 GooglePlay 上发布,我无法更改应用程序的源代码。

请任何人帮忙。

android firebase firebase-cloud-messaging firebase-notifications

10
推荐指数
1
解决办法
1974
查看次数

使用PowerMockito模拟私有方法

我正在使用PowerMockito模拟私有方法调用(privateApi),但它仍然进行privateApi调用,而这又调用另一个thirdPartCall.当thirdPartyCall抛出异常时,我遇到了问题.据我所知,如果我在模拟privateApi,它不应该进入方法实现细节并返回模拟响应.

public class MyClient {

    public void publicApi() {
        System.out.println("In publicApi");
        int result = 0;
        try {
            result = privateApi("hello", 1);
        } catch (Exception e) {
            Assert.fail();
        }
        System.out.println("result : "+result);
        if (result == 20) {
            throw new RuntimeException("boom");
        }
    }

    private int privateApi(String whatever, int num) throws Exception {
        System.out.println("In privateAPI");
        thirdPartyCall();
        int resp = 10;
        return resp;
    }

    private void thirdPartyCall() throws Exception{
        System.out.println("In thirdPartyCall");
        //Actual WS call which may be down while running the test cases
    } …
Run Code Online (Sandbox Code Playgroud)

java junit powermock

9
推荐指数
1
解决办法
5万
查看次数

如何在管道中使用通过 ssh 插件发布

我想从 Windows 上托管的 Jenkins SSH 到 linux 服务器并在 linux 机器上执行命令,我尝试通过 ssh 插件安装发布并测试了全局配置中的连接,它工作正常,我不知道下一步如何进行在管道中。任何帮助,将不胜感激。

jenkins jenkins-plugins jenkins-pipeline

7
推荐指数
2
解决办法
1万
查看次数

嵌套的RecyclerView与多视图滞后滚动

我有一个带有多个视图的recyclerView,其中每一行都是recyclerView.当我滚动recyclelerView时,在创建的每一行上都是滞后的.这是我的一些代码.在下面你可以看到main recyclerView的配置:

LinearLayoutManager mLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
    mRvPromotions.setLayoutManager(mLayoutManager);
    mRvPromotions.setItemViewCacheSize(20);
    mRvPromotions.setDrawingCacheEnabled(true);
    mRvPromotions.setHasFixedSize(true);
    mRvPromotions.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
    mRvPromotions.setAdapter(adapter);
Run Code Online (Sandbox Code Playgroud)

你可以在下面看到在适配器中绑定的内部recyclerView的代码:

mRvPromotion.setLayoutManager(new GridLayoutManager(itemView.getContext(), 3));
    mRvPromotion.setItemViewCacheSize(20);
    mRvPromotion.setDrawingCacheEnabled(true);
    mRvPromotion.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
    adapter = new PlaylistPromotionsRVAdapter(new PlaylistModelCallBack(), new PlaylistPromotionVHFactory());
    mRvPromotion.setAdapter(adapter);
    adapter.submitList(getVM().getPlaylist());
Run Code Online (Sandbox Code Playgroud)

我用mRvPromotion.setNestedScrollingEnabled(false);ViewCompat.setNestedScrollingEnabled(childRecyclerView, false);,但laggy行为存在的钢.对于加载图像,我使用了Fresco并调整了配置.如何防止滞后滚动?

编辑

这是我的适配器:

public class PlaylistRVAdapter extends ListAdapter<PlayListPromotionAndSlider, BaseViewHolder> {

private final PlaylistPageVHFactory mFactory;
private final PublishSubject<PlaylistSliderVHAction> mClickSliderPS = PublishSubject.create();
private final PublishSubject<PlaylistPromotionsVHAction> mClickPromotionPS = PublishSubject.create();

@Inject
PlaylistRVAdapter(@NonNull PlaylistPromotionModelCallBack diffCallback, PlaylistPageVHFactory factory) {
    super(diffCallback);
    mFactory = factory;
}

@NonNull
@Override
public BaseViewHolder onCreateViewHolder(@NonNull ViewGroup …
Run Code Online (Sandbox Code Playgroud)

android recycler-adapter android-recyclerview fresco nestedrecyclerview

6
推荐指数
1
解决办法
961
查看次数

smoothScrollToPosition在嵌套的RecyclerView中不起作用

我有一个recyclerView,每个项目都是一个recyclerView。我想在特定条件下滚动到内部recyclerView的自定义位置。我在innerRecyclerView上使用了这段代码,但是没有用:

innerRecyclerView.smoothScrollToPosition(position); 
Run Code Online (Sandbox Code Playgroud)

和这个:

innerRecyclerView.scrollToPosition(position); 
Run Code Online (Sandbox Code Playgroud)

还有这个:

layoutManager.scrollToPositionWithOffset(position, offset);
Run Code Online (Sandbox Code Playgroud)

现在我有两个问题:

1)是否可以滚动到内部recyclerView的自定义位置?

2)如果可能的话,怎么办?

这是初始化主recyclerView:

LinearLayoutManager layoutManager = new LinearLayoutManager(getContext(), RecyclerView.VERTICAL, false);
        adapter = new FreightsListRVAdapter(new FreightListCallBack(), new FreightListVHFactory());
        rvFreightsList.setLayoutManager(layoutManager);
        rvFreightsList.setItemViewCacheSize(30);
        rvFreightsList.setNestedScrollingEnabled(true);
        rvFreightsList.setAdapter(adapter);
Run Code Online (Sandbox Code Playgroud)

这是初始化innerRecyclerview:

LinearLayoutManager layoutManager = new LinearLayoutManager(itemView.getContext(), RecyclerView.VERTICAL, false);
        layoutManager.setItemPrefetchEnabled(true);
        layoutManager.setInitialPrefetchItemCount(7);
        rvFreights.setNestedScrollingEnabled(false);
        rvFreights.setLayoutManager(layoutManager);
        rvFreights.setItemViewCacheSize(20);

        adapter = new FreightsRVAdapter(new FreightCallBack(), new FreightSingleVHFactory());
        rvFreights.setAdapter(adapter);
Run Code Online (Sandbox Code Playgroud)

这是我的主要recyclerView适配器:

public class FreightsListRVAdapter extends ListAdapter<FreightListModel, FreightListVH> {

    private final FreightListVHFactory mFactory;
    private final PublishSubject<FreightListVHAction> mClickUserPS = PublishSubject.create();

    @Inject
    public FreightsListRVAdapter(@NonNull FreightListCallBack diffCallback, FreightListVHFactory factory) {
        super(diffCallback);
        mFactory = factory; …
Run Code Online (Sandbox Code Playgroud)

android android-recyclerview nestedrecyclerview

6
推荐指数
1
解决办法
388
查看次数