小编Sha*_*dow的帖子

滚动垂直时,为从小到大的图像创建动画

我正在创建图像,当向上滚动时,图像应该放大,剩余的图像应该变小.同样,当第二张图像被推高时,它应该放大并显示.我使用手风琴类型,但没有任何作用.我搜索但找不到.

在iPhone,它有功能,但我找不到如何为Android创建.这是为了

在此输入图像描述

在android中实现相同的效果.

我使用ScaleAnimation隐藏和显示布局来打开图像放置在布局中的位置.但那也行不通.

if(openLayout == panel1){
    panel1.startAnimation(new ScaleAnimToHide(1.0f, 1.0f, 1.0f, 0.0f, 200, panel1, true));
}
Run Code Online (Sandbox Code Playgroud)

有人可以帮我解决这个问题吗?

提前致谢!!

android android-intent android-animation android-layout

13
推荐指数
1
解决办法
2147
查看次数

如何给评级栏明星安卓之间的间距?

嗨,我使用自定义评级栏与自定义图像.我需要在星星之间提供空间.当我增加最小高度和最大高度时,星形图像保持不变.

   <RelativeLayout
    android:id="@+id/RelativeLayout01"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="10dp" 
    android:padding="5dp">

    <TextView
        android:id="@+id/allreviews"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:text="Rating"
        android:layout_marginLeft="8dp"
        android:textSize="14sp" />

        <RatingBar
        android:id="@+id/reviewallrating"
        style="@style/customRatingBar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="3dp"
        android:layout_toRightOf="@+id/allreviews"
        android:isIndicator="false"
        android:numStars="5"
        android:stepSize="0.1" />

   </RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

款式:@ drawable/star_rating_bar_full 12dip 12dip

   star_rating_bar_full.xml:

   <?xml version="1.0" encoding="utf-8"?>
 <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:id="@+android:id/background"
      android:drawable="@drawable/star_ratingbar_full_empty" />
   <!--     <item android:id="@+android:id/secondaryProgress"
      android:drawable="@drawable/star_ratingbar_full_empty" /> -->
      <item android:id="@+android:id/progress"
      android:drawable="@drawable/star_ratingbar_full_filled" />
      </layer-list>

star_ratingbar_full_empty:

   <?xml version="1.0" encoding="utf-8"?>

  <!-- This is the rating bar drawable that is used to
   show a filled cookie. -->
    <selector
   xmlns:android="http://schemas.android.com/apk/res/android">

   <item android:state_pressed="true"
  android:state_window_focused="true"
  android:drawable="@drawable/star_gray" …
Run Code Online (Sandbox Code Playgroud)

android ratingbar

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

如何处理try catch异常android

我正在使用方法getBitmap来显示图像.当我使用它作为方法时,如果它返回位图显示图像但是如果它返回null,则捕获异常.但是如果输入的url也是错误的,它应该处理FileNotFoundException.如何处理两个异常并在UI中显示?

public Bitmap getBitmap(final String src) {

        try {
              InputStream stream = null;
              URL url = new URL(src);
         java.net.URL url = new java.net.URL(src);
              URLConnection connection = url.openConnection();

            InputStream input = connection.getInputStream();
            myBitmaps = BitmapFactory.decodeStream(input);    
           return myBitmaps;        
         } catch (IOException e) {
            e.printStackTrace(); 
            Log.e("IO","IO"+e);
            return null;
        } 
        catch(OutOfMemoryError e1) {
             e1.printStackTrace();  
             Log.e("Memory exceptions","exceptions"+e1);
             return null;
        }
        }
Run Code Online (Sandbox Code Playgroud)

在活动中,我已经这样给了

    Bitmap filename=service.getBitmap(url_box.getText().toString());
    if(file_name!=null)
        {
          displaybitmap(file_name);
        } 
    else
       {  //Toast.makeText("Memory Error");
       //my question is how to handle two exception in UI where memory error …
Run Code Online (Sandbox Code Playgroud)

android exception-handling bitmap filenotfoundexception out-of-memory

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

如何从左到右android为textview应用颜色过渡?

嗨,我需要为 textview 应用颜色过渡,然后移动到下一个屏幕。我尝试过的是,我尝试使用可跨越字符串在 textview 中使用静态颜色,但我无法在 textview 上应用动态颜色过渡。这是我尝试过的。

public class AppActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    TextView tv = (TextView) findViewById(R.id.text);
    Spannable text = new SpannableStringBuilder("Loading..");
    setSpan(tv, text);
    tv.setText(text);
}

private void setSpan(TextView tv, Spannable text) {
    int blueColor = 0xff0000ff;
    int redColor = 0xffff0000;
    ForegroundColorSpan blue = new ForegroundColorSpan(blueColor);
    ForegroundColorSpan red = new ForegroundColorSpan(redColor);
    HalfColorApply o = new HalfColorApply("o", tv, blueColor, redColor);
    text.setSpan(blue, 0, 1, 0);
    text.setSpan(o, 1, 2, 0);
    text.setSpan(red, 2, text.length(), 0); …
Run Code Online (Sandbox Code Playgroud)

android textview android-animation

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

警报管理器不按特定的给定时间间隔工作

嗨我正在使用报警管理器3分钟的特定时间间隔,我开始监控.它有时工作,突然我注意到有不规则的时间间隔,这是不正确的!你可以在附件日志中看到"20-Jul-2016 12:22:03 pm"时间变化!我连接了手机并关闭了屏幕并进行了监控!每3分钟,我点击服务器并获得响应为1.但是,有一次,它需要5分钟才能到达服务器!这个奇怪的问题为何发生?

这是代码.

 public void startAt3() {
    Intent alarmIntent = new Intent(ActivityTracking.this, AlarmReceiver.class);
    pendingIntent = PendingIntent.getBroadcast(ActivityTracking.this, 0, alarmIntent, 0);
    AlarmManager manager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
                        /* Set the alarm */
    Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(System.currentTimeMillis());
    /* Repeating on every 3 minute interval */
    manager.setInexactRepeating(AlarmManager.RTC_WAKEUP,
            calendar.getTimeInMillis(),
            180000L, pendingIntent);
    String mydate = java.text.DateFormat.getDateTimeInstance().format(Calendar.getInstance().getTime());
    Log.e("alarm",mydate);

}
Run Code Online (Sandbox Code Playgroud)

AlarmReceiver:

   public class AlarmReceiver extends WakefulBroadcastReceiver    {//AlarmReceiver class
@Override
public void onReceive(Context context, Intent intent) {//onReceive method
    String mydate = java.text.DateFormat.getDateTimeInstance().format(Calendar.getInstance().getTime());
    Log.e("alarm",mydate);
    Intent service = …
Run Code Online (Sandbox Code Playgroud)

android broadcastreceiver alarmmanager android-wake-lock android-broadcastreceiver

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

在进度搜索栏通知未显示在DownloadManager android中

我正在从webview下载文件.但是, 在使用DownloadManager时,它不会显示与此类似的正在进行的下载通知.它只是在后台操作.下载过程中如何显示状态栏通知.我能够获取下载的文件但是如何在通知中显示正在进行的过程?

我使用了"request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE);" 但它没有显示正在进行的过程.请指导我做错了什么.

这是我用过的代码.

mWebview.setDownloadListener(new DownloadListener() {
            @Override
            public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
                DownloadManager.Request request = new DownloadManager.Request(
                        Uri.parse(url));
                request.setMimeType("pdf");


                String cookies = CookieManager.getInstance().getCookie(url);


                request.addRequestHeader("cookie", cookies);


                request.addRequestHeader("User-Agent", userAgent);


                request.setDescription("Downloading file...");


                request.setTitle(URLUtil.guessFileName(url, contentDisposition,
                        "pdf"));


                request.allowScanningByMediaScanner();
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
      //clueless why it's not working..    
    request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE);
                } else {
                    request.setShowRunningNotification(true);
                }

                //request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
                request.setDestinationInExternalPublicDir(
                        Environment.DIRECTORY_DOWNLOADS, URLUtil.guessFileName(
                                url, contentDisposition, "pdf"));
                dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
                downloadReference = dm.enqueue(request);
                IntentFilter filter = new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE); …
Run Code Online (Sandbox Code Playgroud)

android android-notifications android-download-manager

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

如何解决已定义的资源条目

我正在使用 aosp 并在运行命令后:

make 2>&1 | tee build-log.txt
Run Code Online (Sandbox Code Playgroud)

我收到很多错误,例如:

packages/apps/Settings/res/values/aliases.xml:19: error: Resource entry confirm_lock_pattern is already defined.
res/layout/confirm_lock_pattern.xml:0: Originally defined here.

packages/apps/Settings/res/values/aliases.xml:20: error: Resource entry confirm_lock_password is already defined.
res/layout/confirm_lock_password.xml:0: Originally defined here.

packages/apps/Settings/res/values/strings.xml:5193: error: Resource entry enable_verbose_log_vpu is already defined.
packages/apps/Settings/res/values/strings.xml:5189: Originally defined here.
Run Code Online (Sandbox Code Playgroud)

当我检查特定文件 aliases.xml 和 strings.xml 时,

别名.xml:

<item name="confirm_lock_pattern" type="layout">@layout/confirm_lock_pattern_base</item>
 <item name="confirm_lock_password" type="layout">@layout/confirm_lock_password_base</item>
Run Code Online (Sandbox Code Playgroud)

字符串.xml:

string android cmake android-source

5
推荐指数
0
解决办法
155
查看次数

如何在webview中为手机和平板电脑提供两个链接?

我有两个链接,例如:说facebook.com和m.facebook.com.如果是Android手机,我想

打开m.facebook.com.如果是Android平板电脑,我想打开facebook.com链接.我想做的

webview.怎么可能?

android android-widget android-intent android-layout

4
推荐指数
1
解决办法
280
查看次数

如何使两个类别的Pager Sliding Tab Strip同样适合屏幕android?

我正在使用寻呼机滑动标签条,我在右侧获得额外的空间.如何在选项卡中同样适合两个类别?

我的代码如下:

    PagerSlidingTabStrip tabs = (PagerSlidingTabStrip)findViewById(R.id.tabs);
    tabs.setIndicatorColor(Color.BLUE);
    tabs.setIndicatorHeight(2);
    mPager = (ViewPager) findViewById(R.id.pager);
    FragmentManager fm = getSupportFragmentManager();
    ViewPagerAdapter adapter = new ViewPagerAdapter(fm);
    mPager.setAdapter(adapter);
    tabs.setViewPager(mPager);
    tabs.setShouldExpand(true);

        public class ViewPagerAdapter extends FragmentPagerAdapter {

    // Declare the number of ViewPager pages
    //final int PAGE_COUNT = 2;

    public ViewPagerAdapter(android.support.v4.app.FragmentManager fm) {
        super(fm);
    }
    private final String[] TITLES = { "SIGN IN", "REGISTER"};

    @Override
    public CharSequence getPageTitle(int position) {
        return TITLES[position];
    }
Run Code Online (Sandbox Code Playgroud)

我的xml是:

  <RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<com.views.PagerSlidingTabStrip
    android:id="@+id/tabs"
    android:layout_width="match_parent"
    android:layout_height="48dip"
    android:background="@drawable/background_tabs" /> …
Run Code Online (Sandbox Code Playgroud)

android android-viewpager android-pageradapter

4
推荐指数
1
解决办法
5949
查看次数

如何删除x轴标签底部的额外空间,即低于零mpandroidchart

嗨,我使用了MpAndroidChart库.我在图表的底部提到了标签,但它需要额外的空间来分配标签,即低于0的值.如何减少或消除零底部的空间?

你可以看到下面的截图,其中0和标签之间有一个巨大的空间.如何删除该间距?

在此输入图像描述

  barChart = (BarChart) findViewById(R.id.chart);
    XAxis xAxis = barChart.getXAxis();
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    YAxis leftAxis = barChart.getAxisLeft();
    leftAxis.setDrawAxisLine(true);
    leftAxis.setDrawGridLines(true);
    YAxis rightAxis = barChart.getAxisRight();
    rightAxis.setDrawAxisLine(true);
    rightAxis.setDrawGridLines(true);
Run Code Online (Sandbox Code Playgroud)

android bar-chart mpandroidchart

4
推荐指数
1
解决办法
2537
查看次数