私は私の手に奇妙な問題があります。私は、SearchViewウィジェットのヒントテキストを垂直方向にセンタリングして、虫めがねとクローズアイコンに揃えるようにする必要があります。しかし、私はこれが右に近いアイコンと完全に整合していることがわかりました、コメントアウト行で虫眼鏡を動かさずに、SearchViewのヒントテキストのみをどのように整列させるのですか?
SearchView sv = (SearchView) view.findViewById(R.id.search);
int id = sv.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);
int searchPlate = sv.getContext().getResources().getIdentifier("android:id/search_plate", null, null);
int searchMagIcon = sv.getContext().getResources().getIdentifier("android:id/search_mag_icon", null, null);
ImageView magIcon = (ImageView) sv.findViewById(searchMagIcon); View searchPlateView = sv.findViewById(searchPlate);
EditText searchText = (EditText) sv.findViewById(id); searchText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13);
//searchText.setHint("Some test hint text here");
searchPlateView.setBackgroundColor(Color.WHITE);
searchText.setHintTextColor(Color.parseColor("#D8D8D8"));
sv.setIconified(false);
sv.clearFocus();
:
ここで私がこれまで持っているものの抜粋です虫眼鏡のアイコンが消えます。私はhttp://nlopez.io/how-to-style-the-actionbar-searchview-programmatically/
はしかし、これがヒントテキストと虫眼鏡の両方を移動し、他のいくつかの奇妙なものをしたこの資料に記載されている、リフレクションを使用してみました。私の観察から、上記のコード(私はアンドロイドコードベースから精査しました)では、虫眼鏡は実際にヒントテキストに結びついているようですが、虫眼鏡はそれ自身のものだと思われますか?私は虫眼鏡IDからImageViewを作成するなど、それを試してみることにしました。しかし何もそれから出て来なかった。
虫眼鏡は 'ImageSpan'ですので、ヒントテキストに結びついています。 – Karakuri
私は何を求めているのですか?虫眼鏡をそのままにしてヒントテキストを移動しますか? – David