Android 棒棒糖前的材料颜色控制亮点

Android 棒棒糖前的材料颜色控制亮点,android,Android,我不知道如何获得我的列表按钮(从ListView)和滚动边界效果使用colorControlHighlight主题颜色 这是我的主题 <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@

我不知道如何获得我的列表按钮(从ListView)和滚动边界效果使用colorControlHighlight主题颜色

这是我的主题

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimary</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:textColor">@color/colorAccent</item>
    <item name="android:textColorSecondary">@color/colorAccent</item>
    <item name="android:textColorTertiary">@color/colorAccent</item>
    <item name="colorControlHighlight">@color/colorPrimary</item>
    <item name="colorControlActivated">@color/colorPrimary</item>
    <item name="textAllCaps">false</item>
</style>

@颜色/原色
@颜色/原色
@颜色/颜色重音
@颜色/颜色重音
@颜色/颜色重音
@颜色/颜色重音
@颜色/原色
@颜色/原色
假的
v21:


@颜色/原色
@颜色/原色
@颜色/颜色重音
@颜色/颜色重音
@颜色/颜色重音
@颜色/颜色重音
@颜色/原色
@颜色/颜色透明
@颜色/原色
假的
列表片段:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:id="@+id/page1">

<android.support.design.widget.TabLayout
    android:id="@+id/tabLayout"
    android:layout_width="match_parent"
    android:layout_height="30dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignParentTop="true"
    android:layout_margin="10dp"
    android:background="@android:color/white"
    app:tabIndicatorHeight="0dp"
    app:tabTextAppearance="@style/AppTheme.FilterTabTextAppearance"
    app:tabTextColor="@color/colorAccent"
    app:tabSelectedTextColor="@android:color/white"/>

<ListView
    android:id="@android:id/list"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_below="@+id/tabLayout"/>
</RelativeLayout>


棒棒糖前有没有类似的colorControlHighlight?

您是如何创建按钮的?你能包含那个XML吗?只需用更多内容编辑我的帖子你发布的列表行项目似乎缺少最外层的布局已修复,但没有什么特别之处。你是如何创建按钮的?您可以包含该XML吗?只需使用更多内容编辑我的帖子您发布的列表行项目似乎缺少最外层的布局已修复,但这里没有什么特别之处
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:id="@+id/page1">

<android.support.design.widget.TabLayout
    android:id="@+id/tabLayout"
    android:layout_width="match_parent"
    android:layout_height="30dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignParentTop="true"
    android:layout_margin="10dp"
    android:background="@android:color/white"
    app:tabIndicatorHeight="0dp"
    app:tabTextAppearance="@style/AppTheme.FilterTabTextAppearance"
    app:tabTextColor="@color/colorAccent"
    app:tabSelectedTextColor="@android:color/white"/>

<ListView
    android:id="@android:id/list"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_below="@+id/tabLayout"/>
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="10dp"
            android:descendantFocusability="blocksDescendants">

<ImageView
    android:id="@+id/route_thumb"
    android:layout_width="55dp"
    android:layout_height="55dp"
    android:layout_marginRight="10dp"/>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignTop="@+id/route_thumb"
    android:layout_toLeftOf="@+id/route_sponsor_logo"
    android:layout_toRightOf="@+id/route_thumb"
    android:layout_toStartOf="@+id/route_sponsor_logo"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="4dp"
        android:orientation="horizontal"
        android:weightSum="1">

        <ImageView
            android:id="@+id/route_activity_icon"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="5dp"/>

        <RatingBar
            android:id="@+id/route_rating"
            android:layout_width="wrap_content"
            android:layout_height="8dp"
            android:layout_gravity="bottom"
            style="@style/Widget.AppCompat.RatingBar.Small"
            android:numStars="5"
            android:progressDrawable="@drawable/ratingbar_color"
            android:stepSize="0.5"/>

    </LinearLayout>

    <com.openrunner.android.views.OpenrunnerTextView
        android:id="@+id/route_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="4dp"
        android:textColor="@color/colorPrimary"
        android:textSize="12sp"
        android:textStyle="bold"
        app:fontName="OpenSans"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <com.openrunner.android.views.OpenrunnerTextView
            android:id="@+id/route_length"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="10dp"
            android:textColor="@color/colorAccentLight"
            android:textSize="10sp"
            android:textStyle="bold"
            app:fontName="OpenSans"/>

        <com.openrunner.android.views.OpenrunnerTextView
            android:id="@+id/route_ascent"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="10dp"
            android:drawableLeft="@drawable/ascent_icon"
            android:drawablePadding="2dp"
            android:textColor="@color/colorAccentLight"
            android:textSize="10sp"
            app:fontName="OpenSans"/>

        <com.openrunner.android.views.OpenrunnerTextView
            android:id="@+id/route_descent"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:drawableLeft="@drawable/descent_icon"
            android:drawablePadding="2dp"
            android:textColor="@color/colorAccentLight"
            android:textSize="10sp"
            app:fontName="OpenSans"/>
    </LinearLayout>

</LinearLayout>

<ImageView
    android:id="@+id/route_sponsor_logo"
    android:layout_width="55dp"
    android:layout_height="55dp"
    android:layout_alignParentRight="true"
    android:layout_marginLeft="10dp"
    android:scaleType="center"/>

</RelativeLayout>
public class TabRoutesFragment extends ListFragment
{
    private TabLayout tabLayout;
    private RoutesAdapter adapter;

    @Override
    public void onCreate( Bundle savedInstanceState )
    {
        super.onCreate( savedInstanceState );
    }

    @Override
    public View onCreateView( LayoutInflater inflater, ViewGroup container,
                              Bundle savedInstanceState )
    {
        return inflater.inflate( R.layout.fragment_routes, container, false );
    }

    @Override
    public void onViewCreated( View view, Bundle savedInstanceState )
    {
        super.onViewCreated( view, savedInstanceState );

        tabLayout = ( TabLayout ) view.findViewById( R.id.tabLayout );
        final TabLayout.Tab routesTab = tabLayout.newTab();
        final TabLayout.Tab favoritesTab = tabLayout.newTab();
        final TabLayout.Tab gpxTab = tabLayout.newTab();


        routesTab.setText( R.string.routes_my_routes );
        favoritesTab.setText( R.string.routes_my_favorites );
        gpxTab.setText( R.string.routes_imported_gpx );

        tabLayout.addTab( routesTab, 0 );
        tabLayout.addTab( favoritesTab, 1 );
        tabLayout.addTab( gpxTab, 2 );
        tabLayout.setEnabled( false );

        tabLayout.setOnTabSelectedListener( new TabLayout.OnTabSelectedListener()
        {
            @Override
            public void onTabSelected( TabLayout.Tab tab )
            {
                if( adapter != null ) adapter.getFilter().filter( String.valueOf( tab.getPosition() ) );
            }

            @Override
            public void onTabUnselected( TabLayout.Tab tab )
            {

            }

            @Override
            public void onTabReselected( TabLayout.Tab tab )
            {

            }
        }  );

        LinearLayout tabLayoutView = ( LinearLayout ) tabLayout.getChildAt( 0 );

        for ( int i = 0; i < 3; i++ )
        {
            LinearLayout tabView = ( LinearLayout ) tabLayoutView.getChildAt( i );

            if ( i == 0 ) tabView.setBackgroundResource( R.drawable.filter_tab_rounded_left_background_selector );
            else if ( i == 2 )
                tabView.setBackgroundResource( R.drawable.filter_tab_rounded_right_background_selector );
            else
            {
                final float scale = getResources().getDisplayMetrics().density;
                int margin = ( int ) ( scale + 0.5f );
                ( ( ViewGroup.MarginLayoutParams ) tabView.getLayoutParams() ).setMargins( -margin, 0, -margin, 0 );
                tabView.setBackgroundResource( R.drawable.filter_tab_rounded_center_background_selector );
            }

            TextView textView = ( TextView ) tabView.getChildAt( 1 );
            textView.setTypeface( FontCache.getTypeFace( getActivity(), "DarwinLight-Regular.ttf" ) );
        }

        //setListShown( false );



        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl( getString( R.string.api_url ) )
                .addConverterFactory( GsonConverterFactory.create() )
                .build();

        RouteApiInterface service = retrofit.create( RouteApiInterface.class );

        Call< Routes > routes = service.getUserRoutes();
        routes.enqueue( new Callback< Routes >()
        {
            @Override
            public void onResponse( Call< Routes > call, Response< Routes > response )
            {
                //for ( RouteDetails route :  )
                //{
                //    adapter.add( route );
                //}
                adapter = new RoutesAdapter( getActivity(), 0 , response.body().getRoutes() );
                //adapter.notifyDataSetChanged();
                setListAdapter( adapter );

                tabLayout.setEnabled( true );
                //setListShown( true );
            }

            @Override
            public void onFailure( Call< Routes > call, Throwable t )
            {

            }
        } );
    }

    @Override
    public void onListItemClick( ListView l, View v, int position, long id )
    {
        super.onListItemClick( l, v, position, id );

        Intent intent = new Intent( getActivity(), RouteDetailsActivity.class );
        intent.putExtra( RouteDetailsActivity.EXTRA_ROUTE_ID, adapter.getItem( position ).getId() );

        startActivity( intent );
    }
}