1

Мне нужно установить перемещение текста или прокрутку текста справа налево. Как я могу использовать эффект выделения для моей темы CustomActionBar в android. Показать, я могу сделать изменения в том же. Я добавляю файлы java и xml и style. Нужна помощькак установить шатер на тему CustomActionBar?

Как я могу использовать его?

**style.xml** 

    <resources xmlns:android="http://schemas.android.com/apk/res/android"> 

    <!-- 
     Base application theme, dependent on API level. This theme is replaced 
     by AppBaseTheme from res/values-vXX/styles.xml on newer devices. 



    --> 
    <style name="AppBaseTheme" parent="Theme.AppCompat.Light"> 
     <!-- 
      Theme customizations available in newer API levels can go in 
      res/values-vXX/styles.xml, while customizations related to 
      backward-compatibility can go here. 



     --> 
    </style> 

    <!-- Application theme. --> 
    <style name="AppTheme" parent="AppBaseTheme"> 
     <!-- All customizations that are NOT specific to a particular API-level can go here. --> 
    </style> 

    <style name="CustomActionBarTheme" parent="@android:style/Theme.Holo.Light.DarkActionBar"> 
     <item name="android:actionBarStyle">@style/MyActionBar</item> 
    </style> 

    <!-- ActionBar styles --> 
    <style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse"> 
     <item name="android:background">#F05B30</item> 
    </style> 

    <style name="fontForNotificationLandingPage"> 
     <item name="android:fontFamily">NotoSerif-Regular</item> 
    </style> 

</resources> 

**New_details.java** 

    package com.example.ourvadodara; 

import android.app.Activity; 
import android.content.Intent; 
import android.graphics.Bitmap; 
import android.os.Bundle; 
import android.util.Log; 
import android.view.Menu; 
import android.view.MenuItem; 
import android.widget.ImageView; 
import android.widget.TextView; 

import static com.example.ourvadodara.News.KEY_TITLE; 
import static com.example.ourvadodara.News.KEY_Details; 
import static com.example.ourvadodara.News.KEY_THUMB_URL; 

public class News_details extends Activity { 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_news_details); 

     getActionBar().setDisplayHomeAsUpEnabled(true); 
     // Bitmap bitmap = (Bitmap) 
     // getIntent().getParcelableExtra(KEY_THUMB_URL); 
     // Bitmap bMapScaled = Bitmap.createScaledBitmap(bitmap,350, 150, true); 
     String title = ""; 
     String details = ""; 
     String path = ""; 

     Intent intent = getIntent(); 
     if (null != intent) { 
      title = intent.getStringExtra(KEY_TITLE); 
      details = intent.getStringExtra(KEY_Details); 
      path = intent.getStringExtra("img_url"); 
     } 

     imageLoader il = new imageLoader(this); 
     il.DisplayImage(path, (ImageView) findViewById(R.id.imgdetails)); 
     Log.i("bitmap", "null"); 

     TextView headlineTxt = (TextView) findViewById(R.id.headlines); 
     headlineTxt.setText(title); 
     getActionBar().setTitle(title); 

     TextView descriptionTxt = (TextView) findViewById(R.id.description); 
     descriptionTxt.setText(details); 

    } 
} 

**activity_news_details.xml** 

    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/scrollView1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="#E6E6E6" > 

    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:background="#E6E6E6" > 

     <ImageView 
      android:id="@+id/imgdetails" 
      android:layout_width="fill_parent" 
      android:layout_height="200dp" 
      android:layout_marginLeft="10dp" 
      android:layout_marginRight="10dp" 
      android:layout_marginTop="23dp" 
      /> 

     <TextView 
      android:id="@+id/description" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/headlines" 
      android:layout_marginLeft="10dp" 
      android:layout_marginRight="10dp" 
      android:layout_marginTop="3dp" 
      android:background="@drawable/rounded_corner" 
      android:padding="10dp" 
      android:scrollbars="horizontal" /> 

     <TextView 
      android:id="@+id/headlines" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:layout_below="@+id/imgdetails" 
      android:layout_marginLeft="10dp" 
      android:layout_marginRight="10dp" 
      android:layout_marginTop="5dp" 
      android:background="@drawable/rounded_corner" 
      android:padding="10dp" 
      android:textAlignment="gravity" 
      android:textAppearance="?android:attr/textAppearanceMedium" 
      android:textSize="23sp" 
      android:textStyle="bold" 
      android:ellipsize="marquee" 
      android:scrollHorizontally="true" 
      android:marqueeRepeatLimit="marquee_forever" 
      android:singleLine="true" /> 
    </RelativeLayout> 

</ScrollView> 

ответ

0

Try This

// make the title scroll! 
// find the title TextView 

TextView title = (TextView) findViewById(android.R.id.title); 
// set the ellipsize mode to MARQUEE and make it scroll only once 
title.setEllipsize(TruncateAt.MARQUEE); 
title.setMarqueeRepeatLimit(1); 
// in order to start strolling, it has to be focusable and focused 
title.setFocusable(true); 
title.setFocusableInTouchMode(true); 
title.requestFocus(); 
+0

Здесь я хочу, чтобы прокручивать текст в ActionBar .... –

+0

android.R.id.title увидеть это –

+0

его используется для заголовка по умолчанию идентификатор –